问题
my experience with cache in Android using Phonegap .
1. I want to create one app which should work online as well as offline.
2. If internet connectivity is there it should use otherwise use the history.
Now it working with the online ..but i need to work my app in off line too. for the checking network connection :
function onDeviceReady() {
navigator.network.isReachable("phonegap.com", reachableCallback, {});
navigator.notification.alert("Server Is Ready");
}
// Check network status
//
function reachableCallback(reachability) {
// There is no consistency on the format of reachability
var networkState = reachability.code || reachability;
var states = {};
states[NetworkStatus.NOT_REACHABLE] = 'No network connection';
states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
alert('Connection type: ' + states[networkState]);
}
Can any one help me to access my my app while there is no any nwtwork connection(offline)
回答1:
Use this:
<html manifest="cache.manifest">
instead of <html>
.
And create a new file in the same directory named cache.manifest
.
The contents of that file should look like this
CACHE MANIFEST index.html blabla.png
来源:https://stackoverflow.com/questions/14891537/android-offline-and-online-apps-using-cache-phonegap