Android的离线和在线应用程序缓存使用PhoneGap的&(Android Offline an

2019-08-17 00:06发布

使用PhoneGap的我的缓存经验的Android。

  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.

现在它..但我需要工作,我在离线应用程序太联机工作。 用于检查网络连接:

    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]);
  }

任何一个可以帮助我来访问我的我的应用程序,而没有任何nwtwork连接(离线)

Answer 1:

使用此: <html manifest="cache.manifest">而不是<html>

并创建一个名为同一个目录中的新文件cache.manifest

该文件的内容应该是这样的

CACHE MANIFEST index.html的blabla.png



文章来源: Android Offline and online Apps using cache & Phonegap