Sometime it is required to navigate user in webview on back press button rather than to exit webview so for this you can use the following code :
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTIONDOWN){
switch(keyCode)
{
case KeyEvent.KEYCODEBACK:
if (mWebView.canGoBack()) {
mWebView.goBack();
} else {
cancel();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}
here you can set some properties on webview like this :
mWebView.getSettings().setJavaScriptEnabled(true);
0 Comment(s)