webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
webView.getSettings().setDomStorageEnabled(true);
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
webView.getSettings().setAppCachePath(appCachePath);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAppCacheEnabled(true);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
{
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
}
webView.loadUrl(URL);
答案 0 :(得分:0)
我不知道你究竟在尝试什么,但你可以完全尝试这个
start.sh
然后,
private void saveHtmlFile() {
String path = Environment.getExternalStorageDirectory().getPath();
String fileName = DateFormat.format("dd_MM_yyyy_hh_mm_ss", System.currentTimeMillis()).toString();
fileName = fileName + ".html";
File file = new File(path, fileName);
String html = "<html><head><title>Title</title></head><body>This is random text.</body></html>";
try {
FileOutputStream out = new FileOutputStream(file);
byte[] data = html.getBytes();
out.write(data);
out.close();
Log.e(TAG, "File Save : " + file.getPath());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
...
class LoadListener{
public void processHTML(String html)
{
Log.e("result",html);
}
}
...
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new LoadListener(), "HTMLOUT");
或者,您可以根据您的要求尝试此操作。!