• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps WebViewCLient too slow to be used

dpmihai

Lurker
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.PluginState.ON);
webView.getSettings().setRenderPriority(RenderPriority.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOAD_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
 
Back
Top Bottom