0
votes

I have an Activity in my app which has a Webview in it which opens a URL provided to it and is then redirected to the landing page of the website. The issue I'm facing is once the user is on landing page the redirection is same page redirection i.e. if the landing page is

www.example.com/landing

The redirection is

www.example.com/landing/#other_page

Which does not call the

onPageStarted(WebView view, String url, Bitmap favicon)

of the webview, but

onPageFinished(WebView view, String url)

is called.

Is there a way to track when the redirect is starting to load since I need to log the time required to load a page even if the page is same page redirection.

Thanks in advance!

Edit: According to the documentation:

onPageStarted will not be called when the contents of an embedded frame changes, i.e. clicking a link whose target is an iframe, it will also not be called for fragment navigations (navigations to #fragment_id).

Which is exactly my case. Is there any other way to track the start and end of loading of fragment navigation?

1

1 Answers

0
votes

I think you are looking for that method

webView.setWebViewClient(new WebViewClient() {

    @Override 
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
          Log.d("Webview", url);
          return false;
    } 
});