fbritop Well-Known Member Licensed User Longtime User Jul 29, 2021 #1 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. Package visibility in Android 11 | Android Developers Android 11 introduces changes to package visibility that affect apps targeting Android 11. developer.android.com
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. Package visibility in Android 11 | Android Developers Android 11 introduces changes to package visibility that affect apps targeting Android 11. developer.android.com
agraham Expert Licensed User Longtime User Jul 29, 2021 #2 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
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.
agraham Expert Licensed User Longtime User Jul 29, 2021 #3 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
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.
Erel B4X founder Staff member Licensed User Longtime User Jul 30, 2021 #4 This is not a bug. Moved to the questions forum. Upvote 0