I am writing an app where the user is present with a list of URLs. To make it appear more faster, I want to detect the Wi-Fi state and load the URLs in the background, so when the user picks a URL, they are quickly presented the data specially when they are connected to Wi-Fi. Is there a way I can do this?
Yes, using shouldInterceptRequest. Which you can use to detect if you have a cached version of the requested URL and return an input stream to the cache which the WebView will use instead of loading it from ze webz
For versions before honeycomb, it might be possible to use shouldOverrideUrlLoading, calling webview.loadData(datafromcache, "text/html", "UTF-8"); and return true.
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