I want to show a progress bar while loading an url in my WebView
and I want it to be gone if the requested page is finished loading.
Most of the answers that I found (e.g. this one) override the method WebViewClient.shouldOverrideUrlLoading(...)
.
But why? According to this answer it isn't really necessary to call this method - but why do all the other answers do it?
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.
If I just override the method WebViewClient.onPageFinished(...)
it get's called like I'd expect it to. So I could just implement a progress bar in there without even overriding the other method?
Notify the host application that a page has finished loading. This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet. To get the notification for the new Picture, use onNewPicture(WebView, Picture).
Best regards, winklerrr