简体   繁体   English

如何在android浏览器中默认打开Chrome浏览器中的网页

[英]how to open web page in chrome browser by default in android

I try to open my web page as default in chrome how could i do it . 我尝试打开我的网页作为默认的铬我怎么能这样做。 MyCode Is: MyCode是:

       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 run this activity not found exception shown error 当我运行此活动时未发现异常显示错误

Try this instead, 试试这个,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM