Due to " Package visibility in Android 11", I can't get a list of all installed apps, not even directly querying with the package name. All connections to other apps must be set into the androidmanifest.
Many "package manager" extensions exist, but the ones which work, only work in the companion app. In the apk version, only basic apps are "shown" (calc, camera etc) thus I can't find any way to connect my apps, to check if another app is installed and which version. This is important for me because I'm developing an "app store" application, and I need to monitor which apps are installed and which version they are in, for possible updates. Would anyone say something?
tl;dr Is there some way to actually get a list of all installed apps (in API 30)? Is there some way to get the version of an installed app?
I believe this may only impact on devices with Android 11 +, the extensions still appear to work on Android 10 & less devices with the new AI2 targeting API 30 (only tested in companion though)
Indeed I use Android 11. I guess something has to get updated. I also tried asking for permission QUERY_ALL_PACKAGES, but it just won't work, at first it says permission denied and afterwards it never asks again anyway. I think the permission must be declared inside the extension
Edit your APK with the editor APK and add this permission directly to the manifest. Google considers this a dangerous permission, the user's apps list should be confidential, and only certain types of apps will be able to claim this permission. Google will verify apps with this permission and incompatible apps will be removed from the Play Store.
See here: The limited package visibility reduces the number of apps that appear to be installed on a device, from your app's perspective.
You might want to add the permission QUERY_ALL_PACKAGES into the manifest. If you publish your app on Google Play, your app's use of this permission is subject to approval based on an upcoming policy. To add that permission into the manifest, you can use the Manifest Generator by Atom_Developer.
I used Atom's manifest extension to add the QUERY_ALL_PACKAGES permission, but it added it in the wrong point in the manifest file. It should add it under the <manifest> tag, not under the <application>.
It would be nice to choose the point of injection at the manifest extension.
Also the package manager could auto-require the QUERY_ALL_PACKAGES permission, because without it, it doesn't do much in android 11+ [ edit: this was wrong. QUERY_ALL_PACKAGES is not endorsed for apps that don't really need it, and they are very few. And google doesn't want it so although it works it's not good practice, it is cool for things like app managers and other apps that have a reason to be able to see all installed apps on the phone ]
As a workaround, I use TaifunFile extension to check if /android/data/package_name folder exists. This works surprisingly well, but when an app is installed, its data folder doesn't get created until the app's first launch. Also there's no way to get the version.
Thanks for the info, I managed to build a simple extension which just adds the QUERY_ALL_PACKAGES permission into the manifest. Works great. Here it is
The extension is a blank rush project. The simple function that it has is like "hello world". It's nothing, it's not used, it just exists as a placeholder for more code. The only thing I did was:
I typed "rush create projectname"
Edited the manifest (added the uses-permission line)
Typed "rush build"
So the function you probably see is there by default. I just don't know if it will build without any functions so I left it there. Less work for me.