如何显示android默认浏览器名称和版本?

时间:2019-04-11 16:15:41

标签: java android android-browser

我需要在android中显示默认的浏览器名称和版本。 我不是在寻找chrome或firefox等。

1 个答案:

答案 0 :(得分:0)

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
            PackageManager pm = getPackageManager();

            final ResolveInfo mInfo = pm.resolveActivity(i, 0);

            PackageInfo pInfo = null;

            try {
                 pInfo = getPackageManager().getPackageInfo(
                        mInfo.activityInfo.packageName, PackageManager.GET_META_DATA);

            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }

            Toast.makeText(getApplicationContext()
                    ,pm.getApplicationLabel(mInfo.activityInfo.applicationInfo)
                            + " version " + pInfo.versionName,
                    Toast.LENGTH_LONG)
                    .show();