If your are loading webpage on android webview and need to go on previously loaded webpage on webview, then this is nice trick to go to the previous page over a webview. Just add following method in your java file.
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (mWebView.canGoBack() == true)
{
mWebView.goBack();
}
else
{
finish();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}
No comments:
Post a Comment