如何在android中以编程方式获取基于Chromium的WebView的版本号?

时间:2014-10-31 05:52:29

标签: android webview

我想访问基于铬的webview的版本号,是否可以通过编程方式获得?

围绕此指针的任何指针都会有所帮助。谢谢!

2 个答案:

答案 0 :(得分:1)

 new WebView(context).getSettings().getUserAgentString();

答案 1 :(得分:1)

试试这个:

PackageManager pm = getPackageManager();
        try {
            PackageInfo pi = pm.getPackageInfo("com.google.android.webview", 0);
            Log.d(TAG, "version name: " + pi.versionName);
            Log.d(TAG, "version code: " + pi.versionCode);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Android System WebView is not found");
        }


        WebView webView = new WebView(getApplicationContext());
        String useragent=webView.getSettings().getUserAgentString();

        Log.e(TAG, "useragent: " + useragent);