1

Is there any different behaviors about the WebView class on Android 2.2 and 3.1 ?

Here you go some informations I got testing the same app on two different devices, the first one with Android 2.2 and the another one 3.1

  • The app's target is 2.1
  • The page that I want to access is an ASP.net page

Running on 2.2

  • shouldOverrideUrlLoading is called normally
  • onPageStarted and onPageFinished are called more than once
  • onNewPicture from webview is called once, when the page ends the loading

Running on 3.1

  • shouldOverrideUrlLoading isn't called, only webView.load(url) is enough to do the same work
  • onPageStarted and onPageFinished are called once
  • onNewPicture from webview isnt called

My problem is. I need to show a dialog while the page is loading, and I don't know how to do that with these differences.

If I create the dialog on onPageStarted and close it on onPageFinished it will show and close more than once on 2.2, but on 3.1 it will works fine

Otherwise, if I create the dialog on shouldOverrideUrlLoading and close it on onNewPicture it will works fine on 2.2 but on 3.1 it won't even appear.

Leandro Silva
  • 804
  • 1
  • 9
  • 28

1 Answers1

1

I used the following:

Android WebView progress bar

to put a progress bar on a webview while it was loading, your could implement the same, bringing up a view when the percentage loaded is less than 100% and taking it down when it is 100%. I implemented this for an Android >= 3.0 type device though.

Community
  • 1
  • 1
trumpetlicks
  • 7,033
  • 2
  • 19
  • 33
  • I can't use WebChromeClient because I need to show the page and the user won't be able to navigate trhough other links. WebChromeClient give you a bar on the top of the screen that the user can change the link. Using the default WebViewClient I have the different behaviours that I mentioned above. – Leandro Silva Jun 27 '12 at 16:56
  • Not true, I have standard WebView objects running in my app, and there is NO link bar at the top!!! I have implemented my own progress metering. Now the caviat is that my app is in 3.0 and above! – trumpetlicks Jun 27 '12 at 17:37
  • The point is: I need to set WebChromeClient and WebViewClient to have a similar aproach that I want. I was trying to use one or another, not both. So, I did a progressbar using the activity.setprogress on the onProgressChange of WebChromeClient. My real attempt was to show a dialog with a progressbar inside, but I can use this approach otherwise. Thanks a bunch ! – Leandro Silva Jun 27 '12 at 18:17