androidwebviewandroid-websettings

How to disable the content touch in WebView without afecting the double tap zoom .


Acually i wanted to load the content in the webview , which is in a xhtml file .

I want to disable the accessibility to the content . Click on the link/texts must not navigate to that particular page .

More particularly , I have the contents page of a book in the xhtml file and click on the contents must not navigate to the particular page .

WebView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
       return true;
    }  
});

Will work good but this stops the doulble tap zoom as well . I want to stop accessing the content without affecting the tap zoom .

And one more is that , what does webview.getSettings().setAllowContentAccess(false); refer to in webview .

Thanks in Advance .


Solution

  • If you only want to prevent navigations (user following links) then you need to use the shouldOverrideUrlLoading API:

    webview.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
           return true;
        }
    });