Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

app cache doesn't work in the android device (works well on the chrome browser)

I'm trying to use app cache to approve the performance.

I have been guided in various sites. (ex. http://xguru.net/621 ... )

make cache.man file, set mime-type as text/cache-manifest.

Problem is...

it works well at the Google chrome browser, but does not work in my android phone.

I tested at ICS and Gingerbread.

This is manifest file .

CACHE MANIFEST
# manifest version v0.1 

CACHE:
./programs.png
./video.png

NETWORK:
* 

and then, I set my webview like this.

getSettings().setAppCacheEnabled(true);
getSettings().setDomStorageEnabled(true);
getSettings().setPluginsEnabled(true);
getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);

(I changed the cacheMode to LOAD_NORMAL, NO_CACHE, but it's not different.)

To see the cache state, I use this site. http://jonathanstark.com/blog/2009/09/27/debugging-html-5-offline-application-cache/

var cacheStatusValues = [];
cacheStatusValues[0] = 'uncached';
cacheStatusValues[1] = 'idle';
cacheStatusValues[2] = 'checking';
cacheStatusValues[3] = 'downloading';
cacheStatusValues[4] = 'updateready';
cacheStatusValues[5] = 'obsolete';

var cache = window.applicationCache;
cache.addEventListener('cached', logEvent, false);
cache.addEventListener('checking', logEvent, false);
cache.addEventListener('downloading', logEvent, false);
cache.addEventListener('error', logEvent, false);
cache.addEventListener('noupdate', logEvent, false);
cache.addEventListener('obsolete', logEvent, false);
cache.addEventListener('progress', logEvent, false);
cache.addEventListener('updateready', logEvent, false);

function logEvent(e) {
    var online, status, type, message;
    online = (navigator.onLine) ? 'yes' : 'no';
    status = cacheStatusValues[cache.status];
    type = e.type;
    message = 'online: ' + online;
    message+= ', event: ' + type;
    message+= ', status: ' + status;
    if (type == 'error' && navigator.onLine) {
        message+= ' (prolly a syntax error in manifest)';
    }
    console.log(message);
}

window.applicationCache.addEventListener(
    'updateready',
    function(){
        window.applicationCache.swapCache();
        console.log('swap cache has been called');
    },
    false
);

Lastly, This is the log I see on my android phone.

[cache Resource] app cache support! 
[cache Resource] DOWNLOADING 
[cache Resource] event online: yes, event: checking, status: uncached 
[cache Resource] event online: yes, event: downloading, status: uncached 
[cache Resource] event online: yes, event: progress, status: uncached 
[cache Resource] event online: yes, event: progress, status: uncached 
[cache Resource] event online: yes, event: error, status: uncached (prolly a syntax error in manifest) 

Images are downloaded but we get the error at last line. So it is always in a uncached.

I guess the problem is on the webview setting or android application. But i cannot handle it.

give me a tip to use app cache.. plz...

like image 736
jieun Avatar asked Jul 12 '12 04:07

jieun


People also ask

Why Chrome is not working properly in Android?

Next: Troubleshoot Chrome crash problems If it works in another browser, try uninstalling and reinstalling Chrome. There could be something wrong with your Chrome profile that's causing problems. Uninstall Chrome and make sure to check the box to delete browsing data. Then, reinstall Chrome.

Why some sites are not opening in Chrome Android?

Outdated browsing data remains to be one of the most prominent reasons behind Chrome's failure to load up web pages. So, if the above solutions don't work out, you can try clearing cache and cookies from Chrome.

Can Android apps run on Chrome browser?

You can find and download Android apps on your Chromebook. Your Chromebook doesn't automatically download the same Android apps that are on your phone or tablet, so you must download them again.

How do I view cached data in Chrome Android?

Chrome for AndroidTap Chrome menu > Settings. Tap (Advanced) Privacy. From the "Time Range" drop-down menu, select All Time. Check Cookies and Site data and Cached Images and Files.


1 Answers

Indirectly the answer linked by yugidroid led me to the right line. The blog which is linked in the answer shows what to do:

    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    webView.getSettings().setAppCachePath(appCachePath);

I removed those lines again for testing: same error - readded: no error!

like image 77
Marvin Emil Brach Avatar answered Oct 20 '22 13:10

Marvin Emil Brach