从Android应用程序打开本机浏览器

我有一个安装了多个浏览器的 Android手机,我可能会也可能不会将浏览器设置为认值.

所以,我的问题是……

>从我的应用程序,如何强制只在NATIVE android浏览器中打开一个链接
>有没有办法让我知道浏览器是否设置为认值?

解决方法

From my App,How do I force open a link only in the NATIVE android
browser?

Intent intent = new Intent();
ComponentName comp = new ComponentName("com.google.android.browser","com.google.android.browser.browserActivity");
intent.setComponent(comp);
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.broWSABLE");
Uri uri = Uri.parse(url);
intent.setData(uri);
try
{
    startActivity(intent);
 }
 catch (Exception e)
 {
   e.printstacktrace();
 }

Is there a way I can kNow if there is a browser set to default or not?

PackageManager packageManager = getPackageManager();

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("URL"));

List<ResolveInfo> list = packageManager.queryIntentActivities(intent,0);

if (list.size() > 0) {
    for (ResolveInfo resolveInfo : list) {
       resolveInfo.isDefault();// will let u kNow if the app is set to default
    }

} else {
    //No apps available
}

相关文章

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