gpt4 book ai didi

android - WebView 适用于 android 2.3.3,在 4.0.1 上显示空白页面

转载 作者:太空宇宙 更新时间:2023-11-03 13:30:43 24 4
gpt4 key购买 nike

我不认为这是重复的,但是 this question可能是相关的。

如标题所示:这在 android 2.3.3 上完美运行,在 4.0.1 上随机显示空白页面。它通常首先工作,然后开始显示空白页面,直到应用程序重新安装。

我用来显示一个简单(仅 html)网页的代码如下:

@Override
public void afterTextChanged(final Editable arg0){
final String result = getResult();
final String base64 = encode(result);
//This is the WebView
results.loadData(base64, "text/html; charset=utf-8", "base64");
}

private String encode(final String value){
try{
final byte[] bytes = value.getBytes("UTF-8");
final String base64 = Base64.encodeToString(bytes,
android.util.Base64.DEFAULT);
return base64;
}
catch(UnsupportedEncodingException e){
return "YOULOOZE";
}
}

最佳答案

检查您的 HTML 格式是否正确。我不确定它验证的 Doctype。

这发生在我身上是因为我用过

<script ... />

代替

<script ...></script>

任何微小的错误都会让您的 webview 无提示地失败。

关于android - WebView 适用于 android 2.3.3,在 4.0.1 上显示空白页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13700567/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com