android – 启动浏览器意图与自定义类 – 找不到活动

我想为给定的URL专门运行认的 Android浏览器.我正在使用这段代码
Intent i = new Intent();
i.setAction("android.intent.action.VIEW"); 
i.addCategory("android.intent.category.broWSABLE");
i.setClassName("com.google.android.browser","com.android.browser.browserActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setData(Uri.parse(url));
startActivity(i);

我收到的错误是:

Unable to find explicit activity class {
com.google.android.browser/com.android.browser.browserActivity}; 
have you declared this activity in your AndroidManifest.xml?

我也试图通过包过滤目的:

i.setPackage("com.google.android.browser");

而不是setClassName,但无效:

No Activity found to handle Intent { act=android.intent.action.VIEW 
cat=[android.intent.category.broWSABLE] 
dat=http://www.google.com/ flg=0x10000000 pkg=android }

我还尝试添加< uses-library android:name =“com.google.android.browser”/>到清单.

在这里遗漏了什么吗?

PS:我不喜欢使用startActivity(新的Intent(Intent.ACTION_VIEW,Uri.parse(“http://www.google.com”))),因为它将列出浏览Intent的所有选择.

解决方法

我用这个,没关系
intent.setComponent(new ComponentName("com.android.browser","com.android.browser.browserActivity"));

我想你知道什么错了.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...