美文网首页
WebView Crash on Android 5-5.1 (

WebView Crash on Android 5-5.1 (

作者: Seachal | 来源:发表于2019-12-26 11:14 被阅读0次

    重写一下 WebView。

    public class LollipopFixedWebView extends WebView {
        public LollipopFixedWebView(Context context) {
            super(getFixedContext(context));
        }
    
        public LollipopFixedWebView(Context context, AttributeSet attrs) {
            super(getFixedContext(context), attrs);
        }
    
        public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
            super(getFixedContext(context), attrs, defStyleAttr);
        }
    
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
            super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);
        }
    
        public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {
            super(getFixedContext(context), attrs, defStyleAttr, privateBrowsing);
        }
    
        public static Context getFixedContext(Context context) {
            return context.createConfigurationContext(new Configuration());
        }
    }
    
    

    参考: https://stackoverflow.com/questions/41025200/android-view-inflateexception-error-inflating-class-android-webkit-webview

    相关文章

      网友评论

          本文标题:WebView Crash on Android 5-5.1 (

          本文链接:https://www.haomeiwen.com/subject/kzekoctx.html