Android中如何显示本地HTML

来源:互联网 发布:二手工作站笔记本 知乎 编辑:程序博客网 时间:2024/06/05 14:58
/方法一:

webview = (WebView) findViewById(R.id.webview); 
webview.getSettings().setJavaScriptEnabled(true); 
webview.loadUrl("content://com.android.htmlfileprovider/sdcard/index.html"); 


//方法二:
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);

//方法三:
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");

原创粉丝点击