Is there a way to tell which version of the webkit software is used in the Android browser on some specific handset?
What would be really g开发者_JS百科reat is if there is a URL you can browse to get that information. But any other way would be good too. If you know the webkit version, you know how much html5 suport to expect.
On Android 2.3.3, at least, the version of Webkit is reflected in the user agent string.
When I go to WhatsMyUserAgent.com on my Android device with 2.3.3 (Cyanogenmod 7.0.3), I get:
Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; HTC Vision Build/FRF91) AppleWebKit/533.1 (KHTML; like Gecko) Version/4.0 Mobile Safari/533.1
This site has a summary for you http://jimbergman.net/webkit-version-in-android-version/
When you type javascript:alert(navigator.userAgent)
in the location bar you'll see the WebKit version listed e.g.
Emulator Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; GT-N8000 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
WebView webView = new WebView(getApplicationContext());
String useragent=webView.getSettings().getUserAgentString();
The useragent is the reuslt like:
Mozilla/5.0 (Linux; Android 4.4.2; SM-N900 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
Also we can use
PackageInfo pi = getPackageManager().getPackageInfo("com.google.android.webview", 0);
String version = pi.versionName;
There's a Javascript library from several years ago that can do this. Not sure how up-to-date it is: http://trac.webkit.org/wiki/DetectingWebKit
精彩评论