I have an app that loads a webpage and it works while online. I've added a cache.manifest file to my pages, and this seems to work perfect when using browsers on my android phone, and also when testing on my desktop.
When opening the app, and i open a few pages, they get cached.
After that, i disable all Wifi & 3G connections, and re-open the app. At that point, the pages that i opened previously can be shown, but the ones that i did not open give me the error: "Web page not available".
So this means that some caching is done, but the webviewclient is not actually caching everything that's displayed in my cache.manifest file.
An example page can be found here: http://www.mobileevolution.be/apps/FitceCongress/android/gsm/home.php
The manifest contains the following info:
CACHE MANIFEST
# 30-05-2013 20h11 1152gg2dfdfdfd
CACHE:
committees.php
congressprogram.php
home.php
../../congressprogram.xml
../../partnerprogram.xml
information.php
partnerprogram.php
sponsors.php
style/style.css
registration.php
http://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900
http://themes.googleusercontent.com/static/fonts/roboto/v8/Hgo13k-tfSpn0qi1SFdUfT8E0i7KZn-EPnyo3HZu7kw.woff
http://themes.googleusercontent.com/static/fonts/roboto/v8/2UX7WLTfW3W8TclTUvlFyQ.woff
http://themes.googleusercontent.com/static/fonts/roboto/v8/RxZJdnzeo3R5zSexge8UUT8E0i7KZn-EPnyo3HZu7kw.woff
http://themes.googleusercontent.com/static/fonts/roboto/v8/d-6IYplOFocCacKzxwXSOD8E0i7KZn-EPnyo3HZu7kw.woff
http://themes.googleusercontent.com/static/fonts/roboto/v8/mnpfi9pxYH-Go5UiibESIj8E0i7KZn-EPnyo3HZu7kw.woff
http://themes.googleusercontent.com/static/fonts/roboto/v8/Hgo13k-tfSpn0qi1SFdUffY6323mHUZFJMgTvxaG2iE.eot
http://themes.googleusercontent.com/static/fonts/roboto/v8/5YB-ifwqHP20Yn46l_BDhA.eot
http://themes.googleusercontent.com/static/fonts/roboto/v8/RxZJdnzeo3R5zSexge8UUfY6323mHUZFJMgTvxaG2iE.eot
http://themes.googleusercontent.com/static/fonts/roboto/v8/d-6IYplOFocCacKzxwXSOPY6323mHUZFJMgTvxaG2iE.eot
http://themes.googleusercontent.com/static/fonts/roboto/v8/mnpfi9pxYH-Go5UiibESIvY6323mHUZFJMgTvxaG2iE.eot
The cache settings in Android seem to be correct according to other threads on this forum:
webView1.getSettings().setJavaScriptEnabled(true); // enable javascript
cm = (ConnectivityManager) this.getSystemService(Activity.CONNECTIVITY_SERVICE);
if(cm != null && cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected()){
webView1.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
}
else{
webView1.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ONLY);
}
webView1.getSettings().setDomStorageEnabled(true);
webView1.getSettings().setAppCacheMaxSize(1024 * 1024 * 8);
String appCachePath = getApplicationContext().getCacheDir()
.getAbsolutePath();
webView1.getSettings().setAppCachePath("/data/data/be.mobileevolution.fitcecongress/cache");
//webView1.getSettings().setAppCachePath(appCachePath);
webView1.getSettings().setAllowFileAccess(true);
webView1.getSettings().setAppCacheEnabled(true);
I'm creating the webviewclient like this:
webView1.setWebViewClient(new WebViewClient(){
I think the following thread is the same problem as mine, but no real answer was given: Webview not loading offline cached data
Does anyone have any clarification why all of the files in cache.manifest are not being downloaded on the app? Or maybe the cache.manifest does not work at all in the webview and the caching was done natively by the app? But in the browser it works ok!
Thanks, Grts, Lars