Answers for "how to handle back button in webview android"

0

how to handle back button in webview android

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                if (mWebView.canGoBack()) {
                    mWebView.goBack();
                } else {
                    finish();
                }
                return true;
        }

    }
    return super.onKeyDown(keyCode, event);
}
Posted by: Guest on May-28-2020

Code answers related to "how to handle back button in webview android"

Browse Popular Code Answers by Language