Android获取默认浏览器信息

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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;
        }
    }