Code example for WebView

Methods: canGoBackdestroygoBack, removeAllViews

0
 
	@Override 
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// Check if the key event was the BACK key and if there's history 
		if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView != null
				&& myWebView.canGoBack()) {
			myWebView.goBack();
			return true; 
		} 
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			close(); 
		} 
 
		return super.onKeyDown(keyCode, event);
	} 
 
	private void close() { 
 
		if (myWebView != null) {
			myWebView.removeAllViews();
			myWebView.destroy();
		} 
		finish();
	} 
 
	// ------------------------------------------------------------ 
Connect your IDE to all the code out there  Get Codota for Java