Code example for WebView

Methods: canGoBackgetUrlgoBack

0
        webView.restoreState(savedInstanceState);
    } 
 
    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack() && !isIndexPage()) {
            webView.goBack();
            return true; 
        } 
 
        return super.onKeyDown(keyCode, event);
    } 
 
    private boolean isIndexPage() { 
        return webView.getUrl().equals(LOCAL_URL) || webView.getUrl().equals(LOCAL_URL + "/index.html");
    } 
 
 
} 
Experience pair programming with AI  Get Codota for Java