2012-10-14 17 views
5

so AppCache mio web app funziona bene perché l'ho provato su Chrome, anche su Chrome per Android funziona, ma non quando la si inserisce nella mia app Android da una WebView . Ho le seguenti impostazioni:AppCache su Android Webview non scaricare i sorgenti

myWebView = (WebView) v.findViewById(R.id.webView); 
    WebSettings webSettings = myWebView.getSettings(); 
    webSettings.setDomStorageEnabled(true); 
    webSettings.setJavaScriptEnabled(true); 
    webSettings.setSupportMultipleWindows(true); 
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true); 
    webSettings.setAppCacheMaxSize(1024*1024*16); 
    String appCachePath = getActivity().getApplicationContext().getCacheDir().getAbsolutePath(); 
    webSettings.setAppCachePath(appCachePath); 
    webSettings.setAllowFileAccess(true); 
    webSettings.setAppCacheEnabled(true); 
    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); 
    webSettings.setDatabaseEnabled(true); 
    String databasePath = "/data/data/" + getActivity().getPackageName() + "/databases/"; 
    webSettings.setDatabasePath(databasePath); 
    webSettings.setGeolocationEnabled(true); 
    webSettings.setSaveFormData(true); 

Ma quando si carica l'applicazione, in logcat posso leggere il seguente

10-15 01:21:43.815: E/SQLiteLog(14278): (1) no such table: CacheGroups 10-15 01:21:43.815: D/WebKit(14278): ERROR: 10-15 01:21:43.815: D/WebKit(14278): Application Cache Storage: failed to execute statement "DELETE FROM CacheGroups" error "no such table: CacheGroups" 10-15 01:21:43.815: D/WebKit(14278): external/webkit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558) : bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&) 10-15 01:21:43.815: E/SQLiteLog(14278): (1) no such table: Caches 10-15 01:21:43.815: D/WebKit(14278): ERROR: 10-15 01:21:43.815: D/WebKit(14278): Application Cache Storage: failed to execute statement "DELETE FROM Caches" error "no such table: Caches" 10-15 01:21:43.815: D/WebKit(14278): external/webkit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558) : bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&) 10-15 01:21:43.815: E/SQLiteLog(14278): (1) no such table: Origins 10-15 01:21:43.815: D/WebKit(14278): ERROR: 10-15 01:21:43.815: D/WebKit(14278): Application Cache Storage: failed to execute statement "DELETE FROM Origins" error "no such table: Origins" 10-15 01:21:43.815: D/WebKit(14278): external/webkit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558) : bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&) 10-15 01:21:43.815: E/SQLiteLog(14278): (1) no such table: DeletedCacheResources

E ovviamente AppCache non funziona =/Sto facendo qualcosa di sbagliato? Grazie!

+0

questo è ancora mi dà fastidio, non riesco proprio a trovare un modo per fare questo lavoro. Eventuali suggerimenti? Grazie :) –

+0

Basta indovinare: provare a chiamare 'setAppCacheEnabled (true)' 'prima setAppCacheMaxSize (1024 * 1024 * 16)' e 'setAppCachePath (appCachePath)'. Inoltre: quale versione di Android stai usando? –

+0

@Alberto Elias Hi hai fatto a scoprire perché la cache non funzionava? Ho lo stesso problema – turtleboy

risposta

0

istituito db prima AppCache e domstore, impostare qualsiasi "parametro" come set * Path()/set * Dimensioni() prima del set * Enabled()

Accanto a questo, potrebbe essere una buona idea se impilare due cache gestite in modo indipendente gli uni sugli altri quando si utilizza

getActivity(). getApplicationContext(). getCacheDir(). getAbsolutePath()

come la directory in cui gestore della cache del WebView dovrebbe archiviare i propri dati

W Quando il gestore cache dell'attività decide di eliminare un file creato dal gestore cache della webview, il gestore cache della webview non viene informato e potrebbe fare affidamento sulla sua esistenza

potrebbe funzionare a lungo, ma un giorno potrebbe diventare un bug alternativo che è difficile da identificare

0

Queste sono le impostazioni che lavorano per me:

CookieSyncManager.createInstance(contextForDialog); 
webView = (WebView) findViewById(R.id.webView1); 

WebSettings settings = webView.getSettings(); 

settings.setRenderPriority(RenderPriority.HIGH); 
settings.setCacheMode(WebSettings.LOAD_DEFAULT); 

settings.setSaveFormData(true); 
settings.setLoadsImagesAutomatically(true); 
settings.setJavaScriptEnabled(true); 
settings.setDatabaseEnabled(true); 
settings.setDomStorageEnabled(true); 
settings.setAppCacheMaxSize(1024*1024*1024*8); 
String sDataPath = context.getDir("database", Context.MODE_PRIVATE).getPath(); 
settings.setDatabasePath(sDataPath); 
settings.setAppCachePath(sDataPath); 
settings.setAllowFileAccess(true); 
settings.setAppCacheEnabled(true); 
settings.setAllowFileAccess(true); 
settings.setGeolocationEnabled(true); 
settings.setSavePassword(true); 

webView.setFocusable(true); 
webView.setFocusableInTouchMode(true); 
settings.setDatabaseEnabled(true); 
settings.setAllowContentAccess(true); 
settings.setLoadsImagesAutomatically(true); 
webView.addJavascriptInterface(this, "AndroidInterface"); 
WebView.setWebViewClient(new routeNavClient()); 
webView.setWebChromeClient(new webChromeClient()); 
CookieManager c = CookieManager.getInstance(); 
c.setAcceptCookie(true); 
Problemi correlati