in Android, Android Code Tips, Programming

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:

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