I want to allow the user to toggle 3G state (ON/OFF) even when the device is connected to Wifi (I read here that disabling 3G while connected to Wifi saves battery).
However, when I check the 3G state when the device is connected to Wifi it always return disconnected.
My code is:
// access to mobile networtk service - 3G
ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
// check mobile status
NetworkInfo.State state = mobile.getState(); // returns Disconnected
Boolean isConnected = mobile.isConnectedOrConnecting(); // returns false
if (isConnected)
{
// Turn 3G off
}
else
{
// Turn 3G on
}