I know there are a few threads on this topic but non of them seem to answer my question. I want to be able to detect when the device has no data connection. I have tried the NetworkInfo route checking if its null, isConnected(), isAvailable() etc. The problem im having is that these work fine (return false or null) when wifi or mobile network are disabled however when they are enabled but there is no signal they return true. Is there any way to detect no data connection due to no signal?
Asked
Active
Viewed 3,664 times
3 Answers
1
build reciver and catch broadcast
-
but how will i get to know that there is no data connectivity, is there a intent to recognise it. – varun bhardwaj Mar 29 '12 at 10:35
-
you need to do this in onRecive manually by calling ConnectivityManager.getNetworkInfo ... read documentation ... – Selvin Mar 29 '12 at 11:01
0
You could try pinging google.com. If there's no response, you can be fairly sure that there's no connection (unless the user is in a country where it is blocked).

Haphazard
- 10,900
- 6
- 43
- 55
0
I use ConnectivityManager.getActiveNetworkInfo.isConnectedOrConnecting()
I just tested it 5 minutes ago to make sure, and if everything is working and I then walk away from my house until my router is no longer within range and the network strength indicator on the status bar shows no network, a call to isConnectedOrConnecting() from within an app returns false.
I take it that's not the behavior you are seeing?

jimkberry
- 1,317
- 7
- 8