我正在从 URL 读取内容并修改字符串并再次在 Webview 中加载数据。但它无法正确加载。附加屏幕截图。随便猜
WebSettings settings = webView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
String base64 = Base64.encodeToString(benefitsCore.getBytes(), Base64.DEFAULT);
webView.loadData(base64, "text/html; charset=utf-8", "base64");
} else {
String header = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
webView.loadData(header + benefitsCore, "text/html; chartset=UTF-8", null);
}
private String rzBenefitsCoreText() {
String rzCoreText = null;
try {
URL url = new URL(getActivity().getResources().getString(R.string.bby_rz_sliver_benefits_url));
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));//"ISO-8859-1")
StringBuilder builder = new StringBuilder();
String inputLine;
while ((inputLine = br.readLine()) != null)
builder.append(inputLine);
rzCoreText = builder.toString().replace("Silver member", "Core member");
Log.i("Data:", rzCoreText);
br.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return rzCoreText;
}