vendredi 15 juillet 2016

Webview onReceivedError called even if loading from cache

I've set my Webview to cache every page it visits (while online). I also need to display a custom view on top of the Webview in case the device goes offline and the users tries to load a webpage and it's not been cached.

It seems that the onReceivedError() method of the WebViewClient class is called even if the page has been loaded from cache, and it sets the same error code, i.e. -2 whick apparently means ERROR_HOST_LOOKUP

Is there a way to determine if the webpage failed and it was NOT loaded from cache, so I can then display a custom view to the user ? And no, I can't disable caching, I need to keep it.

Aucun commentaire:

Enregistrer un commentaire