SoFunction
Updated on 2025-04-08

Webview in Android listens for each URL change instance

Through this, you can listen to the URL changes of webview access in Android:

(new WebViewClient(){
@Override
public void onLoadResource(WebView view, String url) {
 ("hao","WebView3:"+()+"\\n"+" URL3:"+url);
 (view, url);
}
});

Supplementary knowledge:Android: Various listening methods for WebView loading completion

The first method:

setWebViewClient()>>>>>>onPageFinished()

The disadvantage is that mobile phones above 6.0 will only call and respond once, as follows:

(new WebViewClient() {
   @Override
   public void onPageFinished(WebView view, String url)
   {
    (view, url);
    // Loading is complete   }
   @Override
   public void onPageStarted(WebView view, String url, Bitmap favicon)
   {
 
    (view, url, favicon);
    // Loading starts   }
  });

The second method:

setWebChromeClient()>>>>>>onProgressChanged()

(new WebChromeClient() {
   public void onProgressChanged(WebView view, int progress) {
    if (progress == 100) {
      //Loading is complete    }
   }
  });

The above example of webview monitoring of each URL change in Android is all the content I share with you. I hope you can give you a reference and I hope you can support me more.