Code example for WebView: Displaying web pages

Methods: addJavascriptInterfacegetSettingsloadUrlsetVerticalScrollbarOverlaysetWebViewClient

0
	 */ 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		webView = new WebView(this);
		webView.setVerticalScrollbarOverlay(true);
 
		webView.setWebViewClient(new WebViewClient() {
		}); 
 
		// Javascript を有効化。 
		webView.getSettings().setJavaScriptEnabled(true);
 
		// localStorage を有効化。 
		webView.getSettings().setDomStorageEnabled(true);
 
		// Database path の設定。 
		String databasePath = this.getDir("localstorage", Context.MODE_PRIVATE).getPath();
		webView.getSettings().setDatabasePath(databasePath);
 
		webView.addJavascriptInterface(new JSCallback(), "HostApp");
 
		webView.loadUrl("file:///android_asset/index.html");
 
		setContentView(webView);
	} 
 
	private class JSCallback { 
Stop searching for code, let great code find you!  Add Codota to your java IDE