gpt4 book ai didi

android - Android Webview 上的 Appcache 不下载源

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:28:27 26 4
gpt4 key购买 nike

我知道我的网络应用程序的应用程序缓存运行良好,因为我已经在 Chrome 上尝试过它,即使在 Android 版 Chrome 上它也可以运行,但是当从 WebView 将它加载到我的 Android 应用程序中时却没有。我有以下设置:

    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);

但是在加载应用程序时,在 logcat 中我可以阅读以下内容

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

显然 AppCache 不工作 =/我做错了什么吗?谢谢!

最佳答案

在appcache和domstore之前设置db,在 set*Enabled() 之前设置任何“参数”,如 set*Path()/set*Size()

除此之外,如果在使用时将两个独立管理的缓存堆叠在一起可能不是一个好主意

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

作为 webview 的缓存管理器应该存储其数据的目录

当 Activity 的缓存管理器决定删除 webview 的缓存管理器创建的文件时,webview 的缓存管理器不会收到通知,可能会进一步依赖它的存在

可能会工作很长时间,但有一天它可能会变成一个难以识别的交替错误

关于android - Android Webview 上的 Appcache 不下载源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12887558/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com