5

I am trying to intercept the url click in my webview. I want to block certain urls from getting launched when they are clicked in webview.

For that I am overriding shouldOverrideUrlLoading method. But still what ever is return true/false that url is getting launched.

e.g if i want to block http://www.xyz.com I am able to get the url string and able to varify it with my black list urls but it is getting launched irrespective of return value.

I may be wrong at approach I need suggestion

7
  • Have you provided a WebViewClient? Also, why not use the shouldInterceptRequest()-method, which sounds more like what you want. Commented Apr 12, 2012 at 9:51
  • @Lukas Knuth :Thanks yes I have provided webview client will check on shouldInterceptRequest() method Commented Apr 12, 2012 at 9:57
  • 1
    You can use shouldOverrideUrlLoading method and return true, get the URL will be loading, if it's in your black list, then load your own warning view Commented Apr 12, 2012 at 10:06
  • Thanks All : shouldInterceptRequest() method worked as well as shouldOverrideUrlLoading() I did some parsing on received urls from above methods and it worked. :) Commented Apr 12, 2012 at 10:09
  • @dreamtale : Can you please explain this statement "You can use shouldOverrideUrlLoading method and return true, get the URL will be loading" Commented Apr 12, 2012 at 11:05

1 Answer 1

3

try something like this

 @Override public boolean shouldOverrideUrlLoading(WebView wView, String url) { if(url.equals("from your list")){ //DO something } return true; } 

however i dont quite remeber the boolean value.just give it a try....

Sign up to request clarification or add additional context in comments.

1 Comment

It blocks only webview in my app..but I want to block in all browser installed in my device.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.