KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an Android app that simply houses a website. I would like the app to cache the pages of the website for offline use. I'm doing a simple test to see if the cache is working but unfortunately it is failing to load a page i have previously loaded in online mode, when offline. To make things clearer i load the following 2 pages when in online mode. webView.loadUrl("http://www.bmimobile.co.uk/why-bmi.php", getHeaders()); webView.loadUrl("http://www.bmimobile.co.uk/", getHeaders()); . I am hoping that the "why-bmi.php" page is loaded into the cache as well as the subsequent page http://www.bmimobile.co.uk/ . The latter page has a link on it which refers to the first page. If i then come out of the app and turn the network adapter off then go back into the app the " http://www.bmimobile.co.uk/ " page DOES display but when i click the "why-bmi" link that page DOES NOT display. I short toast message displays saying "error loading page". Can anyone tell me why the webview is not caching loaded page for later offline use? Here's the main activity and i've extended the Application object defining the appcachepath. Thanks in advance Matt package uk.bmi.mobile; import java.io.File; import java.util.HashMap; import java.util.Map; import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Bundle; import android.util.Log; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { private WebView webView; private static final String TAG = MainActivity.class.getSimpleName(); ApplicationExt bmiAppObj; //instruct server to set it's headers to make resources cachable
Tags (comma-separated)
Save Edits
Cancel