How about checking the user-agent string?
Log.i("WebViewActivity", "UA: " + mWebView.getSettings().getUserAgentString());
For me, this outputs:
User-agent string: Mozilla/5.0 (Linux; Android 5.0; Nexus 4
Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0
Chrome/37.0.0.0 Mobile Safari/537.36
More info: WebView on Android
In case you override UA string with your own:
String getWebviewVersionInfo() {
// Overridden UA string
String alreadySetUA = mWebView.getSettings().getUserAgentString();
// Next call to getUserAgentString() will get us the default
mWebView.getSettings().setUserAgentString(null);
// Devise a method for parsing the UA string
String webViewVersion =
parseUAForVersion(mWebView.getSettings().getUserAgentString());
// Revert to overriden UA string
mWebView.getSettings().setUserAgentString(alreadySetUA);
return webViewVersion;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…