Webview的loadData()在android 10.0(Q)中不起作用 [英] Webview's loadData() is not working in android 10.0 (Q)

查看:682
本文介绍了Webview的loadData()在android 10.0(Q)中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我正在尝试将HTML代码作为字符串加载到Webview的loadData()中.在此方法上没有任何反应,但相同的方法在sdk 29下面的工作方式却很有吸引力.

Here i am trying to load Html code as string in webview's loadData() .Nothing is happen over this mehtod but same method is working like charm in below sdk 29.

webview.loadData(html_code,"text/html",null);

注意:这里我不对字符串执行任何编码或解码操作.我只是将其作为字符串传递给上述方法.

Note : Here i am not performing any encoding or decoding operation on string.I am simply passing it as string to above method.

推荐答案

使用此代码,它将起作用.

Use this code, it will work.

String newhtml_code = Base64.encodeToString(html_code.getBytes(), Base64.NO_PADDING);
        testWebView.loadData(newhtml_code,"text/html", "base64");

这篇关于Webview的loadData()在android 10.0(Q)中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆