-1

I am developing a Launcher application. I have noticed that camera and gallery have same package name, also Google+ and Photos have same package name. When I try to start camera/gallery it opens the gallery and when I try to start Photos/Google+, I opens Google+.

I am using this code to get list of apps.

Intent i = new Intent(Intent.ACTION_MAIN, null);
i.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> availableActivities = manager.queryIntentActivities(i, 0);

As for Camera, I know that I can use an Intent to start camera when app name is Camera and package name is that of gallery, but there could be many apps with same thing. Is there any generalized solution for all of the apps?

P.S.: This is how I am getting app info

for(ResolveInfo ri : availableActivities) {
    AppItem app = new AppItem();
    app.setLabel(ri.loadLabel(manager));
    app.setName(ri.activityInfo.packageName);
    quick_apps.add(app);
}
Angad Singh
  • 1,032
  • 1
  • 17
  • 36

1 Answers1

1

Although they have the the same package name,but they have diffrent name,Try this to start you activity,use the code below to start activity

 Intent localIntent = new Intent();
    localIntent.setComponent(new ComponentName(
            localResolveInfo.activityInfo.packageName,
            localResolveInfo.activityInfo.name));
    localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try
    {
        startActivity(localIntent);
    } catch (ActivityNotFoundException localActivityNotFoundException)
    {
        Toast.makeText(mContext, "Package not found!", 0).show();
    }