如何在android中默认在chrome浏览器中打开网页
我试着在chrome中默认打开我的网页,我怎么能这样做呢。 MyCode是:如何在android中默认在chrome浏览器中打开网页,android,Android,我试着在chrome中默认打开我的网页,我怎么能这样做呢。 MyCode是: try { Intent i = new Intent("android.intent.action.VIEW"); i.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.example.webviewdemo.MainActivity"));
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
}
当我运行此活动时,未找到异常显示错误请尝试此操作
internetIntent.setComponent(new ComponentName("com.android.chrome","com.android.browser.BrowserActivity"));
internetIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
您有任何网页浏览应用程序吗?首先谢谢,先生,我的要求是默认情况下在chrome浏览器中打开我的网页链接。伙计,我尝试了这个,但得到了12-24 16:21:34.629:android.content.ActivityNotFoundException:找不到显式活动类{com.android.chrome/com.android.browser.BrowserActivity};您是否在AndroidManifest.xml中声明了此活动?12-24 16:21:34.989:D/PowerManager(741):DVFSLock:acquire使用
PackageManger
和Intent
可以检查特定的意图类别,如Intent。类别可浏览
可用于任何应用程序,如果可用,则将该应用程序设置为ComponentName
。阅读此,谢谢sufiyan,但如果我使用了这段代码,那么它将向我显示我不想要的chosse浏览器选项。我只想在chrome浏览器中打开我的Web链接。