Android, how to get the list of the apps that open a URL without using createChooser
To find all the apps that open a URL I would do like this:
Uri uri = Uri.parse(URL);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
Intent intentChooser = Intent.createChooser(intent,"Choose navigator");
activity.startActivity(intentChooser);
The problem is that I don't want to user the Chooser co开发者_JAVA技巧ntrol, because of some developing specifications.
The question is how can I get the list of apps that open URL (that's what I get with the code above) to pass them to an ArrayAdapter / Spinner.
Try asking PackageManager (http://developer.android.com/reference/android/content/pm/PackageManager.html#queryBroadcastReceivers%28android.content.Intent,%20int%29)
Maybe this will do:
Uri uri = Uri.parse(URL);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
List<ResolveInfo> allActivities = queryIntentActivities(intent, 0);
精彩评论