You may have easily found this same code (below) in forums scattered across the Internet but when you used it, you wondered why even though you disabled your WIFI Internet connection, the method still returns true. You find out that the NetworkInfo of type mobile returns true even if your connectivity is offline.

This is a common misconception among developers when using this method in their app and running it in the Android emulator. If it is a normal smartphone, then this will work correctly. But when it comes to the emulator, even I was baffled why it kept returning true.

It seems that by default, the emulator has connectivity on by default. Just press the F8 key to switch between on and off and the method should work the way you want it to.

Related Posts Plugin for WordPress, Blogger...