I'm looking for a way to search in the device all the apps which are capable to filter Intents with action "VIEW" and category "BROWSABLE"?
I found the following links and learned how to list all Intent Filters, but how can I list only those having only the aforementioned parameters?
http://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentActivities%28android.content.Intent,%20int%29
Get intent filter for receivers
How to filter specific apps for ACTION_SEND intent (and set a different text for each app)
Thanks in advance
This code should do more or less what you want. The main problem is that I don't think you will find any activity that filters for CATEGORY_BROWSABLE
without also requiring data of a specific type. I tried it on my phone and I didn't get anything useful until I added the setData()
call on the Intent.
PackageManager manager = getPackageManager();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
// NOTE: Provide some data to help the Intent resolver
intent.setData(Uri.parse("http://www.google.com"));
// Query for all activities that match my filter and request that the filter used
// to match is returned in the ResolveInfo
List<ResolveInfo> infos = manager.queryIntentActivities (intent,
PackageManager.GET_RESOLVED_FILTER);
for (ResolveInfo info : infos) {
ActivityInfo activityInfo = info.activityInfo;
IntentFilter filter = info.filter;
if (filter != null && filter.hasAction(Intent.ACTION_VIEW) &&
filter.hasCategory(Intent.CATEGORY_BROWSABLE)) {
// This activity resolves my Intent with the filter I'm looking for
String activityPackageName = activityInfo.packageName;
String activityName = activityInfo.name;
System.out.println("Activity "+activityPackageName + "/" + activityName);
}
}
}