My application connects to the internet onCreate, it does this in an AsyncTaks class and all works fine. I have some error checking in place to make sure there is internet available and works great if I say put my phone on Flight Mode.
My problem is when I’m on WIFI, where I live the WWW drops out from time to time but the phone still thinks it’s connected. E.g.. the phone is still connected to the WIFI dongle but the WIFI dongle is not connected to the WWW, so when the application opens and tries to connect it gets an error and I get a force close.
How can I do a complete internet connection check onCreate that will cover all bases???
Cheers,
Mike.
One possibility is just to handle the error that you are getting in a better manner. You are getting a force close right now because (I assume) you are getting a
RuntimeExceptionfrom your application. Handling the exceptions and putting up proper messaging to your user might be adequate.Another way is just make one (or a couple) connections to some high available servers to see if it works. For example, something like the following should work:
If you post the exception/error that you are getting and comment on my answer I can edit it with more specifics.