在HTML5应用程序缓存不中的Android PhoneGap的应用程序中使用
我想使用的应用程序缓存HTML5为Android PhoneGap的应用程序,但是这也不行,它不觉得有ApplicationCahce活动。
I'm trying to use application cache in HTML5 for Android PhoneGap Application, but this doesn't work, it doesn't feel with ApplicationCahce Events.
function logEvent(event) {
console.log(event.type);
}
window.applicationCache.addEventListener('checking', logEvent, false);
window.applicationCache.addEventListener('noupdate', logEvent, false);
window.applicationCache.addEventListener('downloading', logEvent, false);
window.applicationCache.addEventListener('progress', logEvent, false);
window.applicationCache.addEventListener('cached', logEvent, false);
window.applicationCache.addEventListener('updateready', logEvent, false);
window.applicationCache.addEventListener('obsolete', logEvent, false);
window.applicationCache.addEventListener('error', logEvent, false);
此外,iOS中的PhoneGap和Android浏览器这个code运行这个链接支持的平台。 应用Cahce支持平台
Also, this code run in iOS PhoneGap and Android Browser and this link for supported platforms. Application Cahce Supported platforms
所以,任何建议将是有益的。
So, any suggestion it would be helpful.
我相信应用程序缓存默认情况下未在web视图功能。你将需要做的是在扩展DroidGap调用Java类:
I believe the application cache is not enabled by default in the WebView. What you will need to do is in the Java class that extends DroidGap call:
this.appView.getSettings().setAppCacheEnabled(true);
在您的onCreate()方法。
in your onCreate() method.
您可能还需要调用:
this.appView.getSettings().setAppCacheMaxSize(sizeInBytes);
this.appView.getSettings().setAppCachePath(pathToCacheDir);
请注意缓存目录必须存在调用setAppCachePath前()。
Please note the cache directory must exist before you call setAppCachePath().
阅读上...
http://developer.android.com/reference/android/webkit/WebSettings.html#setAppCacheEnabled(boolean) http://developer.android.com/reference/android/webkit/WebSettings.html#setAppCacheMaxSize(long) http://developer.android.com/reference/android/webkit/WebSettings.html#setAppCachePath(java.lang.String)