1

我在 Android 中使用 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.

现在它可以在线使用..但我也需要离线使用我的应用程序。检查网络连接:

    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 连接(离线)的情况下,谁能帮我访问我的应用程序

4

1 回答 1

3

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

并在同一目录中创建一个名为cache.manifest.

该文件的内容应如下所示

缓存清单 index.html blabla.png

于 2013-02-15T09:29:06.893 回答