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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.