Monitor WebView url

0

Hello! I am doing some tests in my android application and in 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 button visible). I did some research related to this but I could not clarify my doubts. I would like to know how I can implement such features for my application.

    
asked by anonymous 10.10.2017 / 18:03

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
    }
});
    
10.10.2017 / 19:46