There are 3 different ways of querying installed apps of the user in Android 11.
- If you already know which apps you want to query just mention the
package names inside the
<queries> element in the
AndroidManifest.
<manifest package="com.nikit.app">
<queries>
<package android:name="com.fake.app" />
<package android:name="com.fake.game" />
</queries>
...
</manifest>
- In case you don’t know all the package names of the apps that you
want to query but there is a set of apps with similar functionality
that you want to query then you can use an intent filter inside the
<queries> element according to your requirements like it has been
done in the code snippet below.
<manifest package="com.nikit.app">
<queries>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="image/jpeg" />
</intent>
</queries>
...
</manifest>
The <intent> element looks like <intent-filter> but there are few differences. element has the following restrictions:
- The
<intent> element can have only one <action> element.
- The element can only have the following attributes :
mimeType,
scheme and host.
- If you want to query all the apps of the user like you were doing
earlier, you need to include
QUERY_ALL_PACKAGES permission in the
AndroidManifest. It is a normal permission and it is granted as soon
as the app is installed.
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>