0

Hi,

I am trying to open Chrome app from my application. Code is simple.

I got the package name of Chrome app by using this code:

        PackageManager manager = Values.activity.getPackageManager();

        Intent i = new Intent(Intent.ACTION_MAIN, null);
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        List<ResolveInfo> availableActivities = manager.queryIntentActivities(i, 0);
        for(ResolveInfo ri:availableActivities){
            apps.add(ri.activityInfo.packageName);
        }

        //the package name of Chrome from packagemanager is "com.android.chrome"

And I tried to open Chrome like this:

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.android.chrome");
startActivity( LaunchIntent );

But nothing happens without an error and my logcat says this:

12-28 20:28:52.298: I/ActivityManager(482): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.android.chrome cmp=com.android.chrome/com.google.android.apps.chrome.Main} from pid 20474

What am I missing? Is the package name retrieved from packagemanager wrong?

Edited by pritaeas: Moved to mobile.

1
Contributor
1
Reply
16
Views
3 Years
Discussion Span
Last Post by 9tontruck
0

Sorry for not clearing enough for my goals. I was trying to open another application in my launcher app. But in the main activity in my launcher app which is with default and home filters in manifest cannot open other applications. I don't know why. I just did a workaround.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.