Determine WebView Implementation (System WebView or Chrome)

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()


As a supplementary info to the answer of DataDino, for APIs below 26 here's a chunk of code that would give the desired output:


    Class webViewFactory = Class.forName("android.webkit.WebViewFactory");
    Method method = webViewFactory.getMethod("getLoadedPackageInfo");
    PackageInfo packageInfo = (PackageInfo) method.invoke(null, null);

    if ("com.android.webview".equals(packageInfo.packageName)) {
        // "Android System WebView" is selected
    } else {
        // something else selected
        // in case of chrome it would be "com.android.chrome"
    }


To get the current Android WebView implementation and version I've created this method which should be valid for every API level.

@SuppressLint("PrivateApi")
@SuppressWarnings({"unchecked", "JavaReflectionInvocation"})
public @Nullable PackageInfo getCurrentWebViewPackageInfo() {
    PackageInfo pInfo = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        //starting with Android O (API 26) they added a new method specific for this
        pInfo = WebView.getCurrentWebViewPackage();
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //with Android Lollipop (API 21) they started to update the WebView 
        //as a separate APK with the PlayStore and they added the
        //getLoadedPackageInfo() method to the WebViewFactory class and this
        //should handle the Android 7.0 behaviour changes too
        try {
            Class webViewFactory = Class.forName("android.webkit.WebViewFactory");
            Method method = webViewFactory.getMethod("getLoadedPackageInfo");
            pInfo = (PackageInfo) method.invoke(null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        //before Lollipop the WebView was bundled with the
        //OS, the fixed versions can be found online, for example:
        //Android 4.4 has WebView version 30.0.0.0
        //Android 4.4.3 has WebView version 33.0.0.0
        //etc...
    }
    return pInfo;
}

Then you can evaluate the result

if (pInfo != null) {
    Log.d("WEBVIEW VERSION", pInfo.packageName + ", " + pInfo.versionName);
}

Remember: Immediately after an app update of WebView, a crash could appear as described here: https://stackoverflow.com/a/29809338/2910520, at this moment, this line webViewFactory.getMethod("getLoadedPackageInfo") of the code above would return null. Actually there is nothing you can do to prevent this, (this should not happen if the WebView implementation is taken from Chrome app but is not confirmed).