WebViewClient - onPageStarted () vs shouldOverrideUrlLoading ()?

I am using WebViewClient. Should we see the onPageStarted () callbacks always paired with the shouldOverrideUrlLoading () callback? If I load example.com into my WebView, should we see how both methods get the callback? From the docs:

onPageStarted ()

Notify the host application that the page has started loading. This method is called once for each loading of the main frame, so a page with frames or sets of frames will call onPageStarted once for the main frame. This also means that onPageStarted will not be called when the contents of the inline frame are changed, that is, it clicks the link whose purpose is the iframe.

shouldOverrideUrlLoading ()

Give the host app the ability to take control when the new URL is loaded in the current WebView. If WebViewClient is not provided, by default WebView will ask Activity Manager to select the correct handler for the URL. If provided by WebViewClient, return true to indicate that the host application is processing the URL, and return false to indicate that the current WebView is processing the URL.

I put a log statement in each method, and I see that they are not always conjugated together. In what cases will they not?

thanks

http://developer.android.com/reference/android/webkit/WebViewClient.html

+6
source share
1 answer

I know this question is old, but still answering. AFAIK, mustOverrideUrlLoading () will be called for each URL on the page, where onPageStart () will be called only for the top page URL.

+1
source

Source: https://habr.com/ru/post/911316/


All Articles