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 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系统中获取默认浏览器信息的方法。通过创建特定意图,添加相关类别和数据,利用包管理器查询所有浏览器程序,若存在则返回首个浏览器的ActivityInfo信息,不存在则返回null。

被折叠的 条评论
为什么被折叠?



