Monitor Webview url

Asked

Viewed 356 times

0

Hello! I am doing some tests on my android application and on a certain Activity I intend to put a webview. I would like to monitor the url of this webview, so when the user enters a predetermined url (example: www.google.com) the application performs certain action (example: leave visible button). I did some research related to this but could not clarify my doubts. I would like to know how I can implement such features to my application.

1 answer

1

You can use a Webviewclient to intercept some events.

webView.setWebViewClient(new WebViewClient() {
    @Override public void onPageStarted(WebView view, String url, Bitmap favicon) {
      super.onPageStarted(view, url, favicon);
      // Uma pagina comecou a ser carregada
    }

    @Override public void onPageFinished(WebView view, String url) {
      super.onPageFinished(view, url);
      // Uma pagina terminou de ser carregada
    }

    @Override
    public void onLoadResource(WebView view, String url) {
      super.onLoadResource(view, url);
      // Carregando um recurso
    }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.