mWebView = (WebView) findViewById(R.id.activity_main_webview);
webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setDatabasePath("/data/data/" + mWebView.getContext().getPackageName() + "/databases/");
webSettings.setDomStorageEnabled(true);
webSettings.setAllowFileAccess(true);
webSettings.setAppCacheMaxSize(5 * 1024 * 1024); // 5MB
File cacheDir = getCacheDir();
if (!cacheDir.exists())
cacheDir.mkdirs();
webSettings.setAppCachePath(cacheDir.getPath());
webSettings.setAppCacheEnabled(true);
if (isNetworkAvailable())
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
else
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
CookieSyncManager.createInstance(getApplicationContext());
CookieManager.getInstance().setAcceptCookie(true);
mWebView.loadUrl("http://~~~");
这是我的代码。 这就是错误。
08-06 22:34:45.536 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.536 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.536 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.536 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.546 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.556 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.556 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.566 18343-18343/lk.lk W/dalvikvm: VFY: unable to resolve virtual method 424: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable;
08-06 22:34:45.566 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.576 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.586 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.586 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method lk.lk.MainActivity.access$super
08-06 22:34:45.726 18343-18343/lk.lk D/dalvikvm: Note: class Lcom/lge/mdm/manager/ILGMDMDevicePolicyManager$Stub; has 372 unimplemented (abstract) methods
08-06 22:34:45.746 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.webkit.WebResourceRequest', referenced from method lk.lk.MainActivity$1.access$super
08-06 22:34:45.756 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.webkit.WebResourceRequest', referenced from method lk.lk.MainActivity$1.access$super
08-06 22:34:45.756 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.webkit.ClientCertRequest', referenced from method lk.lk.MainActivity$1.access$super
08-06 22:34:45.756 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.webkit.WebResourceRequest', referenced from method lk.lk.MainActivity$1.access$super
08-06 22:34:45.756 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.webkit.PermissionRequest', referenced from method lk.lk.MainActivity$2.access$super
08-06 22:34:45.756 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.webkit.WebChromeClient$FileChooserParams', referenced from method lk.lk.MainActivity$2.access$super
08-06 22:34:45.756 18343-18343/lk.lk E/dalvikvm: Could not find class 'android.webkit.PermissionRequest', referenced from method lk.lk.MainActivity$2.access$super
08-06 22:34:45.896 18343-18383/lk.lk E/chromium: [ERROR:cache_creator.cc(115)] Unable to create cache
08-06 22:34:45.896 18343-18383/lk.lk E/chromium: [ERROR:appcache_storage_impl.cc(1803)] Failed to open the appcache disk cache.
我不知道为什么我的代码不起作用。 有问题吗?
有时,它运作良好。 (特别是,我安装应用程序后(首次启动)) 但是,当我关闭我的应用并重新启动我的应用时,HTML5缓存无法正常工作。它出现在错误之上。