admin管理员组文章数量:1570456
报错信息:
加载data报的异常
报错机型:
等等 基本都是vivo的
解决方案:
1.重绘WebView ,确保不会直接崩溃,退出程序
public class VivoWebView 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);
}
// To fix Android Lollipop WebView problem create a new configuration on that Android version only
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;
}
}
2.如果出现乱码——》重新设定loadData
//这一步是针对vivo 会出现乱码的情况 小米也有几率出现
webView. loadData(bean.getLabelIntroduce(), "text/html; charset=UTF-8", null);; // 加载定义的代码,并设定编码格式和字符集。
加载url报的错误异常:
解决方案:
上面第一步重写WebView,以及升级"appcompat:appcompat:1.1.0"
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
版权声明:本文标题:android5.1.1的vivo手机,【Android】解决Vivo及5.1低版本 webView适配问题 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1727360289a1110527.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论