Code example for WebView: Displaying web pages

Methods: addJavascriptInterfaceclearCachegetSettingsloadUrlsetBackgroundColorsetWebChromeClient

0
		super.onCreate(savedInstanceState);
 
		setContentView(R.layout.webview_layout);
 
		wView = (WebView) findViewById(R.id.webview);
		wView.getSettings().setJavaScriptEnabled(true);
		wView.setBackgroundColor(0);
		wView.getSettings().setLoadsImagesAutomatically(true);
		wView.clearCache(true);
 
		wView.loadUrl("file:///android_asset/Server/index.html");
 
		wView.setWebChromeClient(new WebChromeClient() {
			@Override 
			public boolean onJsAlert(WebView view, String browser_url, String message, JsResult result) {
				//Required functionality here 
				// Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT); 
				return super.onJsAlert(view, browser_url, message, result);
			} 
		}); 
 
		wView.addJavascriptInterface(new IJavascriptHandler(), "communication");
 
	} 
 
	final class IJavascriptHandler { 
		IJavascriptHandler() { 
Stop searching for code, let great code find you!  Add Codota to your java IDE