Preloading web page in Android (using WebView?)
android, android-activity, android-webview, webview
Solution
According to android's documenation: For obvious security reasons, your application has its own cache, cookie store etc.—it does not share the Browser application's data.
So we can make use of the above info in a smart way by doing this:
Whenever you want to start loading your website, create a new WebView object and request the url from it. the code will look something like this:
WebView view = new WebView(context);
view.loadUrl(myBigWebSite);
Android will cache that webview data and when you request loadUrl from another activity it should be already loaded.
// in your WebView activity
myWebView.loadUrl(myBigWebSite);
For more about webViews visit the documentations page : WebView doc
Problem
I want to pre load a web page in Android. The web page contains both text and graphical elements. The web page will be displayed in the future in an Activity which has not been created yet. As far I understand it a WebView for example has to be tied to an Activity, thus it's not possible to use a WebView for this task. Anyone got any suggestions which does not involve parsing the html page and downloading all the elements "manually"?