/one
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("content://com.android.htmlfileprovider/sdcard/index.html");
//two
Uri uri = Uri.parse("content://com.android.htmlfileprovider/sdcard/01.htm");
Intent intent = new Intent();
intent.setData(uri);
intent.setClassName("com.android.htmlviewer", "com.android.htmlviewer.HTMLViewerActivity");
startActivity(intent);
//three
String encoding = "UTF-8";
String mimeType = "text/html";
final String html =
"<p><a href=/"file:///sdcard/web/acdf2705/">链接google</a></p>"+
"<p><a
href=/"file:///sdcard/ebook/user_defined/browser/localweb//532fa8dc/"&
gt;链接google</a></p>";
mWebView.loadDataWithBaseURL("file://", html,mimeType, encoding, "about:blank");
Android中如何显示本地HTML
最新推荐文章于 2024-04-19 11:37:32 发布
本文介绍了在Android应用中使用WebView加载本地HTML文件的三种不同方式:直接加载、通过Intent启动HTMLViewerActivity以及使用loadDataWithBaseURL加载带有相对路径链接的内容。
836

被折叠的 条评论
为什么被折叠?



