WebViewCLient too slow to be used

 

 

http://androidforums.com/application-development/729511-webviewclient-too-slow-used.html

 

WebViewCLient too slow to be used
 

Hi. 

I use Android 4.2.2 sdk and I have a simple activity that loads a url inside a WebView like:

WebView webView = (WebView) findViewById(R.id.webView);
webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(WebSettings.P luginState.ON);
webView.getSettings().setRenderPriority(RenderPrio rity.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOA D_NO_CACHE);
webView.getSettings().setDomStorageEnabled(true);
webView.loadUrl(....);

This works well and the content is loaded in about 5 seconds inside my emulator.

I want to add a progress dialog and a WebViewClient so the user will not see how the browser is opened:

ProgressDialog progressBar = ProgressDialog.show(MyActivity.this, "MyApplication", "Loading ...");

webView.setWebViewClient(new MyWebViewClient());

private class MyWebViewClient extends WebViewClient {
public void onPageFinished(WebView view, String url) {
Log.d("LOAD : ", "Finished loading URL: " + url);
if (progressBar.isShowing()) {
progressBar.dismiss();
}
}

With this code I see the ProgressDialog but onPageFinished is called after about 3 minutes instead of 5 seconds.

Do you have any clue why is this happening? Is this something related to the emulator?

Thanks,
Mike

 

posted on 2013-09-18 08:12  Omelas  阅读(284)  评论(0编辑  收藏  举报

导航