Android Offline and online Apps using cache & Phonegap

北城以北 提交于 2019-12-21 06:36:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!