0

Is it possible to check if Android WebView can reach the server or not? So if it can't reach the server or a specific website it returns something like false or so? I've searched quite a lot and some people said you can use OnReceivedError() but that doesn't work for some reason... So how can I check if the app can reach the given server (host address).

1 Answer 1

1

This way worked for me: https://stackoverflow.com/q/2001824/446576

Don't rely on webview errors, check connectivity instead.

To test a specific remote host, try to download a page with HttpClient (see https://stackoverflow.com/q/4724491/446576)

3
  • But with that code it won't check if it really has internet connection right? So when wifi is on and connected to a network but the network doesn't have access it doesn't give an error... So it's not totally correct?
    – MartijnG
    Nov 24, 2011 at 19:39
  • With first link, you don't get error, you get a boolean: is there someway to access internet? With second link you can trully test connectivity. You can set timeout too.
    – Francois
    Nov 24, 2011 at 20:46
  • Thank you!! I wIll figure it out.
    – MartijnG
    Nov 24, 2011 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.