in Android

Back in Android’s WebView

When a user navigates a website through a webview, pressing the back button will finish the current activity, instead of going back in the browsing history.

You can change this behavior like this:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
		mWebView.goBack();
		return true;
	}
	return super.onKeyDown(keyCode, event);
}
Share