android vivo5.1版本以下手机webview崩溃

方法一:重写webview构造方法

public class MyWebView extends WebView {
 
    public VivoWebView(Context context) {
        super(getFixedContext(context));
    }
 
    public VivoWebView(Context context, AttributeSet attrs) {
        super(getFixedContext(context), attrs);
    }
 
    public VivoWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(getFixedContext(context), attrs, defStyleAttr);
    }

    private static Context getFixedContext(Context context) {
        if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) // Android Lollipop 5.0 & 5.1
            return context.createConfigurationContext(new Configuration());
        return context;
    }
}

方法二:修改build.gradle appcompat依赖版本

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
 
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容