I'm create a Android Application to show a webpage. When install app in mobile device, the first time run fast.If I click a Button in webpage, charging is fired at moment. But when close app add relaunch, the WebView becomes slow. It takes more time to load and buttons are lag.
I discovered that deleting the folder app_webview on application folder and relaunch application, app run fast. If I closed app and relaunch, app is slow again.
What is the reason for this slowdown? Is it possible to solve it?
This is my config:
mWebView.setListener(this, this);
mWebView.setInitialScale(0);
mWebView.setVerticalScrollBarEnabled(true);
mWebView.setGeolocationEnabled(true);
mWebView.setMixedContentAllowed(true);
mWebView.setCookiesEnabled(true);
mWebView.setThirdPartyCookiesEnabled(true);
mWebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG);
mWebView.addJavascriptInterface(new JavaBridge(this, mWebView), "JavaBridge");
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
String cookies = CookieManager.getInstance().getCookie(url);
Log.d("COOKIE", "All the cookies in a string:" + cookies);
}
});
mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setAppCacheEnabled(false);
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
//Toast.makeText(MainActivity.this, title, Toast.LENGTH_SHORT).show();
}
});
mWebView.addHttpHeader("X-Requested-With", "");
mWebView.loadUrl(url);
Thanks a lot!! Regards