PDA

View Full Version : Network Accessibility



waynew
5th December 2010, 01:03
Small problem here - my application accesses the internet under certain conditions and if the internet is not available or is too slow to respond, the application crashes.
The internet call is made in a separate thread and I do have a timer in that thread.

I added code to check the networkAccessible property before I start the thread to make sure the net is available, but that property always returns -1 whether the network is available or not. So it still crashes when the internet is not available.

Any suggestions?

tbscope
5th December 2010, 05:34
You need to give a lot more information.
A working, minimal and compilable example that demonstrates the problem is needed.

waynew
5th December 2010, 13:32
Ok tbscope, I'll see what I can put together. Probably won't happen until tonight as I have to work this weekend at the office.

squidge
5th December 2010, 13:55
networkAccessible can only tell you (at most) if the physical connection is available. It can not tell you if the internet is available - that would require attempting to connect to somewhere and setting the value of a flag based on the success or failure of that connection.

It is strange however that your application should crash if it can't communicate with a server, but we would need to see your code to determine why.