tommek

I just push the buttons….

Archive for the ‘Emulator’ Category

Android Emulator ConnectivityManager, always returning connected

leave a comment »

I have recently be playing around with the ConnectivityManager in the android emulator. I was trying to detect if the emulator had internet connectivity or not.

ConnectivityManager connec =  (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

connec.getNetworkInfo(0).getState() // = CONNECTED
connec.getNetworkInfo(1).getState() // = CONNECTED

Every time I retrieved the status from the NetworkInfo it would return “CONNECTED”, even when I disconnected from internet.

After doing some hunting around on the issue, I found that you need to manually disable the internet connectivity on the emulator. The emulator does not listen to the computers  network interface so disable the network / internet will not effect the emulator.

To disable internet / network connectivity on the emulator hit F8.

Written by tomkaurin

October 29, 2010 at 6:46 pm

Posted in Android, Emulator