【问题标题】:Android Offline and online Apps using cache & Phonegap使用缓存和 Phonegap 的 Android 离线和在线应用程序
【发布时间】:2013-01-31 05:47:27
【问题描述】:

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

【问题讨论】:

    标签: android cordova mobile browser-cache offline-caching


    【解决方案1】:

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

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

    该文件的内容应如下所示

    缓存清单 索引.html blabla.png

    【讨论】:

    • 好的。但我没有清除这句话:“该文件的内容应该如下所示:CACHE MANIFEST ## Required First Line index.html blabla.png”
    • cache.manifest 的内容必须是指定的格式。第一个like必须是CACHE MANUFEST,其他行需要是你要缓存的文件名。
    • 新行通过它应该是这样的:CACHE MANIFEST \newline\ file.html \new line\ etc.html
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    • 1970-01-01
    • 2011-07-31
    • 1970-01-01
    • 1970-01-01
    • 2014-08-15
    • 2010-10-14
    相关资源
    最近更新 更多