试图弄清楚为什么我无法从我拥有的多个 webviews 中清除缓存,当我在下面以这种方式获取代码时,我似乎遇到了强制关闭错误。但是,当它只有 1 个 webview 时,它工作正常。任何建议的家伙。
由于多个 Web 视图而无法工作的部分
Preference customPref = (Preference) findPreference("clearcache");
customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
// When Cache Preference is clicked
public boolean onPreferenceClick(Preference preference) {
Toast.makeText(getBaseContext(), "Cache Cleared",
Toast.LENGTH_LONG).show();
WebViewClientDemoActivity.web.clearCache(true);
Commercial.web4.clearCache(true);
Community.web2.clearCache(true);
Distributors.web6.clearCache(true);
Downloads.web7.clearCache(true);
EnlightenInfoPage.web4.clearCache(true);
Support.web3.clearCache(true);
return false;
}
});
它的作品只有这个
WebViewClientDemoActivity.web.clearCache(true);
所有 ove webview 都是死的 webviews 并且确实被使用,是我没有的声明东西或类似的东西。
或者,如果您知道清除应用程序缓存而不是数据的方法,只需使用“首选项”单击进行缓存
LOGCAT
08-29 20:46:14.413: E/AndroidRuntime(337): FATAL EXCEPTION: main
08-29 20:46:14.413: E/AndroidRuntime(337): java.lang.NullPointerException
08-29 20:46:14.413: E/AndroidRuntime(337): at com.jaisonbrooks.enlighten.Prefs$1.onPreferenceClick(Prefs.java:60)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.preference.Preference.performClick(Preference.java:812)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:190)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.widget.ListView.performItemClick(ListView.java:3382)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.os.Handler.handleCallback(Handler.java:587)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.os.Handler.dispatchMessage(Handler.java:92)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.os.Looper.loop(Looper.java:123)
08-29 20:46:14.413: E/AndroidRuntime(337): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-29 20:46:14.413: E/AndroidRuntime(337): at java.lang.reflect.Method.invokeNative(Native Method)
08-29 20:46:14.413: E/AndroidRuntime(337): at java.lang.reflect.Method.invoke(Method.java:521)
08-29 20:46:14.413: E/AndroidRuntime(337): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-29 20:46:14.413: E/AndroidRuntime(337): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-29 20:46:14.413: E/AndroidRuntime(337): at dalvik.system.NativeStart.main(Native Method)