Android获取默认浏览器信息
Android系统可以用如下方法获取默认浏览器信息:
public static ActivityInfo getBrowserApp(Context context) {
String default_browser = "android.intent.category.DEFAULT";
String browsable = "android.intent.category.BROWSABLE";
String view = "android.intent.action.VIEW";
Intent intent = new Intent(view);
intent.addCategory(default_browser);
intent.addCategory(browsable);
Uri uri = Uri.parse("http://");
intent.setDataAndType(uri, null);
// 找出手机当前安装的所有浏览器程序
List<ResolveInfo> resolveInfoList = context.getPackageManager().queryIntentActivities(intent, PackageManager.GET_INTENT_FILTERS);
if (resolveInfoList.size() > 0) {
ActivityInfo activityInfo = resolveInfoList.get(0).activityInfo;
String packageName = activityInfo.packageName;
String className = activityInfo.name;
return activityInfo;
} else {
return null;
}
}
更多相关文章
- Android 程序启动界面Demo
- android中获取当前程序路径
- 在android中实现动态跑动的图表实现方法
- 【Android ndk-stack tool】用ndk-stack分析应用native程序异常c
- Android之从Browser中打开本地的应用程序&微信检测是否有对应app
- Android service的开启和绑定,以及调用service的方法
- Android中JNI的使用方法
- 换掉整个程序的bitton样式,以及button的父样式
- 【解决方法】Unexpected namespace prefix “xmlns” found for