I am able to get all the applications which are in Launcher with the help of Intent.CATEGORY_LAUNCHER
.
So for testing I created a test activity, this activity contains a single button, if I press the button, it should display the applications in the device
NOTE: `it should not display specific. for example i needed only Browser it should display all browser applications.`
I tried in this way a small CODE:
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_BROWSER);
List<ResolveInfo> mainLauncherList = getPackageManager().queryIntentActivities(intent, 0);
System.out.println("the list iss = " +mainLauncherList);
}
});
The list is returning only one browser that is single Browser.
If anyone else needed the answer:
list
will contain package information of all browser.Instead of a category, give the intent an action and query the ones that could
ACTION_VIEW
a url, like so:Which returns something like:
And assuming you have more than one browser installed, it will contain them all. Maybe I misunderstood your question but this technically returns the same applications you'd get if you tried launching the intent to open the url.
As to getting the launcher activity of those applications, since you already know how to get all the main applications and by the code I gave, the one you're after, you could match the package names (assumably) to find the launcher one (?)
UPDATE
As I was saying, you get all packages, from the launcher and match them against the packages from the ones that are able to perform the action, be it take a photo, or browse the web. You should be able to get that thing going with this.