Intercepting page loads in WebView

WebView browser = (WebView)findViewById(;
browser.setWebViewClient(new WebViewClient() {
    /* On Android 1.1 shouldOverrideUrlLoading() will be called every time the user clicks a link,
     * but on Android 1.5 it will be called for every page load, even if it was caused by calling loadUrl()! */
    public boolean shouldOverrideUrlLoading(WebView view, String url)
        /* intercept all page load attempts and load instead */
        String myAlternativeURL = "";
        if (!url.equals(myAlternativeURL)) {
            return true;

        return false;


By admin-powenko

Dr. Powen Ko is a teacher and CEO on LoopTek LLC, and like to teaching. if you need to class, please let PowenKo know, he will love to service and sharing. LoopTek web site is

Leave a Reply