Android 11 introduces various changes to strengthen the privacy of the user using the respected app and, also introduces changes related to package visibility on how your apps query and interact with the other apps installed on a device.
The Apps must have to use the <queries> element to define other packages that the app wants to interact with.
Before Android 11, the applications used to obtain the list of all installed applications using methods such as queryIntentActivities() but this lists all the app.
The filtering of the package helps to reduce the information that your app doesn’t require, but that your app can still access it.
Query Intent Filter
Your app might need to query or interact with a set of apps that are serving a specific purpose (like using mail, browsing), but you might not know the specific package names to be included.
In this case, you can use intent filter <intent-filter> tag in your <queries> element.
You can check the below example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<queries> <!-- WebView --> <intent> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> </intent> <intent> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" /> </intent> <intent> <action android:name="android.intent.action.SENDTO"/> <data android:scheme="smsto" android:host="*" /> </intent> <intent> <action android:name="android.intent.action.SEND" /> <!-- Replace with the MIME type that your app works with, if needed. --> <!-- <data android:mimeType="image/jpeg" />--> </intent> </queries> |
Specific package names
In the Manifest, You have to use the <queries> element and, if you have any specific package your app wants to query then you have to add it like the below code.
1 2 3 4 |
<queries> <package android:name="android.speec.action.RECOGNIZE_SPEECH" /><!--This package package filtering to query the Voice recognition --> <package android:name="com.example.test" /><!--Different specific package query--> </queries> |
All apps query
This permission is the recommended way but if, your app needs to query/interact with all installed applications regardless of the components they have.
You can allow your app to see all other installed apps, then you need to add QUERY_ALL_PACKAGES permission.
1 |
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/> |
You can also check out the official documentation provided by Google click here.
. . . . . . . . .
That’s it from my side for today, thanks for reading it until now. You can check our other android blogs Click Here.