Tuesday, March 20, 2012

How to show html page from asserts


mWebView.loadUrl("file:///android_asset/main.html");
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.setScrollContainer(false);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSaveFormData(true);
mWebView.getSettings().setBuiltInZoomControls(false);
mWebView.addJavascriptInterface(new JavaScriptInterface(this),"Android");
mWebView.setWebChromeClient(new WebChromeClient() 
{
 // Show javascript logs in LogCat
 public void onConsoleMessage(String message, int lineNumber,String sourceID) 
 {
  Log.d("MyApplication", message + " -- From line " + lineNumber + " of " + sourceID);
 }

});

No comments: