Prevent crash on devices with bad webview

This commit is contained in:
NekoInverter committed 2021-01-10 19:32:08 +08:00
1 parent 1ad9941355
commit 0c1bf6f0b3
5 files changed
+37

No files matched your search

@@ -0,0 +1,25 @@
package com.hippo.util;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.util.Log;
import androidx.webkit.WebViewCompat;
public class WebViewUtil {
private static final String TAG = "WebViewUtil";
public static boolean available(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return false;
}
PackageInfo webViewPackageInfo = WebViewCompat.getCurrentWebViewPackage(context);
if (webViewPackageInfo == null) {
Log.d(TAG, "WebView not available");
return false;
}
Log.d(TAG, "WebView version: " + webViewPackageInfo.versionName);
return true;
}
}