Code example for WebView: Displaying web pages

Methods: clearCacheclearHistorygetSettingsloadUrlsetScrollBarStylesetWebChromeClientsetWebViewClient

0
		final ProgressDialog dialog = new ProgressDialog(HTMLFormChildActivity.this);
        dialog.setMessage(getString(R.string.form_loading));
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.show();
 
		wv.setWebViewClient(new WebViewClient() {
			@Override			 
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				view.loadUrl(url);
				return true; 
			} 
			 
	        public void onPageFinished(WebView view, String url) {
	        	dialog.dismiss();
	       } 
		}); 
		 
		wv.setWebChromeClient(new WebChromeClient() {
			 
			public void onProgressChanged(WebView view, int progress) {            
				dialog.setProgress(progress);
            } 
			 
			public boolean onConsoleMessage(ConsoleMessage cm) {
			    Log.d("MyApplication", cm.message() + " -- From line "
			                         + cm.lineNumber() + " of "
			                         + cm.sourceId() );
			    return true; 
			  } 
		}); 
 
		// give ourselves a ton of permissions 
		wv.getSettings().setJavaScriptEnabled(true);
		wv.getSettings().setGeolocationEnabled(true);
		wv.getSettings().setDomStorageEnabled(true);
 
		wv.clearCache(true);
		wv.clearHistory();
		 
		// fix a bug with rendering 
		wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
		 
//		wv.addJavascriptInterface(new ChildBridge(new MalnutritionWorkflowManager(null)), "MSF"); 
 
		wv.loadUrl(URLForm);			
	} 
	 
	 
	@Override	 
	public boolean onKeyUp(int keyCode, KeyEvent event) {
Stop searching for code, let great code find you!  Add Codota to your java IDE