I'm using WebViewClient. Should we be seeing onPageStarted() callbacks always paired with an shouldOverrideUrlLoading() callback? If I load example.com in my WebView, should we be seeing both methods get called back? From the docs:
onPageStarted()
Notify the host application that a page has started loading. This method is called once for each main frame load so a page with iframes or framesets will call onPageStarted one time for the main frame. This also means that onPageStarted will not be called when the contents of an embedded frame changes, i.e. clicking a link whose target is an iframe.
shouldOverrideUrlLoading()
Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView. If WebViewClient is not provided, by default WebView will ask Activity Manager to choose the proper handler for the url. If WebViewClient is provided, return true means the host application handles the url, while return false means the current WebView handles the url.
I'm put a log statement in each method, and I see that they're not always paired together. In what cases would they not be?
Thanks
http://developer.android.com/reference/android/webkit/WebViewClient.html
shouldOverrideUrlLoading is called when a new page is about to be opened whereas shouldInterceptRequest is called each time a resource is loaded like a css file, a js file etc.
If you want to deliver a web application (or just a web page) as a part of a client application, you can do it using WebView . The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout.
Android WebView is a system component for the Android operating system (OS) that allows Android apps to display content from the web directly inside an application.
I know this question is old, but answering anyway. AFAIK, the shouldOverrideUrlLoading() will be called for every url in the page where as onPageStart() will be called only for the top url of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With