EVX EVX - 1 year ago 99
Android Question

Restricting WebView to one page only

Hey guys my question is simple, is it possible to restrict WebViews so that when you have let's say one webview for website but you just want the view to stick to that page and only that page?

Great example is I have a twitter WebView that is following a tag. I just want the user to be able to follow that tag not be able to go deeper into twitter stuff.

It's already a pre-set link,

Button--> opens web view with set link to twitter.

So has to be some kind of check for on press or something like I think.

Answer Source

something like this should do it.

myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient() {
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if(url.contains("somedomain.com")) {
    return true;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download