Android Question Package Manager

fbritop

Active Member
Licensed User
Longtime User
When using PackageManager to list installed apps, only default OS apps are listed. This is a known restriction that affects targetSdkVersion>29

No effective way until now for listing apps. For ex, we have several CRM communications channel, one of them is WhatsApp integrated with WhatsApp Business API, we check if the user has whatsapp installed, so we can offer him that channel. Same thing with Telegram.

As I exposed on an Android Question, this feature has some backdoors that can be tweak.

 

agraham

Expert
Licensed User
Longtime User
To answer your original query, to check if WhatsApp is installed add this to your project manifest where packagename is that of the required app to check. You can add more than one package to the queries element.
B4X:
AddManifestText("<queries>
    <package android:name="packagename" />
    <package android:name="anotherpackagename" />
</queries>")
If the package is installed it will show up in the GetInstalledPackages list.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
If you want to get all the packages add this to the manifest
B4X:
AddPermission(android.permission.QUERY_ALL_PACKAGES)
and request permission as usual
B4X:
    Dim rp As RuntimePermissions
    rp.CheckAndRequest( "android.permission.QUERY_ALL_PACKAGES")
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    Log($"QUERY_ALL_PACKAGES = ${Result}"$)
Note that Google will not usually allow this for Play Store apps.
 
Upvote 0
Top