Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine WebView Implementation (System WebView or Chrome)

Android 7.0 allows users (via developer options) to choose the implementation of their WebView. The user can choose the standalone WebView or use the Chrome APK to render WebViews. Reference

Since this potentially means those who use WebViews now have two different code bases to worry about, it would be useful to know which implementation is currently selected.

Is there a way to determine what WebView implementation is selected in Android 7?

like image 431
DataDino Avatar asked Dec 20 '16 03:12

DataDino


People also ask

Is WebView based on Chrome?

No, Chrome for Android is separate from WebView. They're both based on the same code, including a common JavaScript engine and rendering engine.

Which browser does WebView use?

But a wide variety of other Android applications also use it to display web content that isn't a part of the app. The WebView app is based on Chromium, the same open source project that powers the Google Chrome web browser, but it doesn't include all the features present in the full version of Chrome.

How do I know if I have Android System WebView?

If you don't see the app in your app list, you may be running a version of Android where WebView is built in to Chrome instead. If you still have it and want to uninstall it, go to “Settings -> Application Manager -> App Info -> Android System WebView.” The app should be near the top.


2 Answers

Looks like this now available in Android O Preview:

Link: https://developer.android.com/preview/features/managing-webview.html

Starting in Android 7.0 (API level 24), users can choose among several different packages for displaying web content in a WebView object. Android O includes an API for fetching information related to the package that is displaying web content in your app. This API is especially useful when analyzing errors that occur only when your app tries to display web content using a particular package's implementation of WebView.

To use this API, add the logic shown in the following code snippet:

PackageInfo webViewPackageInfo = WebView.getCurrentWebViewPackage();
Log.d(TAG, "WebView version: " + webViewPackageInfo.versionName);

WebView.getCurrentWebViewPackage Documentation: https://developer.android.com/reference/android/webkit/WebView.html#getCurrentWebViewPackage()

like image 91
DataDino Avatar answered Sep 17 '22 12:09

DataDino


There is an appCompat version:

WebViewCompat.getCurrentWebViewPackage(context)

like image 29
tonyo.dev Avatar answered Sep 16 '22 12:09

tonyo.dev