Reputation: 2609
How to know if the intent I am going to publish is going to be answered in advance?
After building an intent, I tried this, which does not work:
Intent fc = ....
PackageManager manager = context.getPackageManager();
List<ResolveInfo> list = manager.queryIntentActivities(fc, 0);
startActivityForResult(fc, 1);
Despite the fact that list
has 0 elements, an app was opened by the intent.
Upvotes: 3
Views: 153
Reputation: 1006614
On Android 11 and higher, to use many (most?) methods on PackageManager
, you need to have a <queries>
element in your manifest, identifying the apps (or criteria for apps) that you want to find via PackageManager
. Without that <queries>
element, the package visibility rules will limit you results to your own app and some system apps.
Upvotes: 2
Reputation: 1508
Or, set MATCH_ALL to prevent any filtering of the results
public static final int MATCH_ALL = 131072;
There are more flags to try. Replace 0 with others.
Upvotes: 0