Android离线和在线应用使用缓存& Phonegap [英] Android Offline and online Apps using cache & Phonegap

查看:195
本文介绍了Android离线和在线应用使用缓存& Phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android使用Phonegap缓存的经验。

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)

推荐答案

使用:
< html manifest =cache。清单> 而不是< html>

文件在 cache.manifest 的同一目录中。

该文件的内容应类似于

CACHE MANIFEST
index.html
blabla.png

CACHE MANIFEST index.html blabla.png

这篇关于Android离线和在线应用使用缓存&amp; Phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆