Instead of a category, indicate the intention of the action and request those that could have an ACTION_VIEW
URL, for example:
Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.google.com")); List<ResolveInfo> mainLauncherList = getPackageManager().queryIntentActivities(intent, 0); Log.e("Browsers","the list iss = " +mainLauncherList);
Which returns something like:
[ResolveInfo{44e9d350 com.android.browser.BrowserActivity p=0 o=0 m=0x208000}]
And if you have more than one browser installed, it will contain all of them. Perhaps I misunderstood your question, but this technically returns the same applications that you would get if you tried to run the intention to open the URL.
As for getting activity to run these applications, since you already know how to get all the main applications and the code I gave, the one you need, you can match the package names (presumably) to find the one (?) Launcher
UPDATE
ArrayList<String> allLaunchers = new ArrayList<String>(); Intent allApps = new Intent(Intent.ACTION_MAIN); List<ResolveInfo> allAppList = getPackageManager().queryIntentActivities(allApps, 0); for(int i =0;i<allAppList.size();i++) allLaunchers.add(allAppList.get(i).activityInfo.packageName); Intent myApps = new Intent(Intent.ACTION_VIEW); myApps.setData(Uri.parse("http://www.google.es")); List<ResolveInfo> myAppList = getPackageManager().queryIntentActivities(myApps, 0); for(int i =0;i<myAppList.size();i++){ if(allLaunchers.contains(myAppList.get(i).activityInfo.packageName)){ Log.e("match",myAppList.get(i).activityInfo.packageName+""); } }
As I said, you get all the packages from the launcher and compare them with the packages from those that are able to perform the action, whether it be a photo or web browsing. You must be able to do this.
source share