美文网首页
WebView在Android 5.0,5.1崩溃解决办法

WebView在Android 5.0,5.1崩溃解决办法

作者: mt大山 | 来源:发表于2021-01-20 09:39 被阅读0次
    public class MyWebView extends WebView {
    
        public MyWebView(Context context) {
            super(getFixedContext(context));
        }
    
        public MyWebView(Context context, AttributeSet attrs) {
            super(getFixedContext(context), attrs);
        }
    
        public MyWebView(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;
        }
    }
    
    

    相关文章

      网友评论

          本文标题:WebView在Android 5.0,5.1崩溃解决办法

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