2

I have a WebView with a WebViewClient with the onRecievedError method set.

But if I set my phone to Airplane mode and the page fails to loadthe above method isn't called, is there any to detect and deal with WebView being unable to load pages?

Ray Britton
  • 8,257
  • 3
  • 23
  • 32

1 Answers1

1

But if I set my phone to Airplane mode and the page fails to loadthe above method isn't called

That method is for errors received from the Web server. In your case, there is no accessible Web server.

is there any to detect and deal with WebView being unable to load pages?

Not generically, AFAIK. You can use ConnectivityManager to determine if you have an Internet connection, which would help in your airplane mode scenario.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Found the code I need: http://stackoverflow.com/questions/4238921/android-detect-whether-there-is-an-internet-connection-available – Ray Britton Dec 02 '10 at 15:39
  • 1
    @raybritton: While that code will help, it does not cover every scenario. You might be connected but blocked by a firewall, for example. – CommonsWare Dec 02 '10 at 15:45
  • So, check if I can reach the server, after running that code? – Ray Britton Dec 02 '10 at 16:05
  • 1
    @raybritton: That's a fine plan. You should also watch for the relevant broadcasts from `ConnectivityManager`, so you know when the state changes and can re-test your ability to reach the server. – CommonsWare Dec 02 '10 at 16:16