How to open a web page in the default Chrome browser in android

I am trying to open my default webpage in chrome, how can I do that. MyCode Is:

       try {
            Intent i = new Intent("android.intent.action.VIEW");
            i.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.example.webviewdemo.MainActivity"));
            i.addCategory("android.intent.category.LAUNCHER");
            i.setData(Uri.parse(url));
            startActivity(i);
        }
        catch(ActivityNotFoundException e)
        {
             //exception raised
            e.printStackTrace();
            // Chrome is probably not installed
        }

      

When I ran this operation, not found error showing showed

+3


source to share


1 answer


Try this instead



internetIntent.setComponent(new ComponentName("com.android.chrome","com.android.browser.BrowserActivity"));
internetIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

      

0


source







All Articles