Question

I'm trying to replicate the application grid that Android have by default, loading all the "launchable" appliactions.

I do it this way.

//generate the intent to get the application list 
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

PackageManager manager = getPackageManager();
applicationList = manager.queryIntentActivities(mainIntent, 0);

//sort the list 
Collections.sort(applicationList, new ResolveInfo.DisplayNameComparator(manager));

//user in calculating percentage. 
if (applicationList.size() > 0 ){
    for (ResolveInfo info : applicationList) {

once I've the list handle it to show the name + icon of the application in a grid view, but when it comes to the camera, I keep getting the Gallery label and icon.

for getting the label I use:

PackageManager manager = getPackageManager();
(String) manager.getApplicationLabel(applicationInfo)

for getting the icon

info.loadIcon(getContext().getPackageManager());

where info is a ApplicationInfo object.

I wonder what could be happening.

so far I've just notice that application but it maybe another.

anyone know how can I get the Camera application from the camera ResolveInfo

while debuging I toke an screen shot this is the information I got for that ResolveInfo

Camera Resolve Info (information)

Thanks in advice. Cesar Glez.

Was it helpful?

Solution

I wonder what could be happening.

You are getting the icon and the label for the application. The "Camera" and the "Gallery" come from a single app with two launchable activities.

You need to get the icon and the label for the activity, not the application. Call loadLabel() and loadIcon() on the ResolveInfo to get the icon and label for the activity that the ResolveInfo points to.

This sample application demonstrates building such a launcher, and it correctly gets the camera activity icon for its entry.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top