0

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
}
Community
  • 1
  • 1
adl
  • 1,865
  • 1
  • 25
  • 32

1 Answers1

1

According what i know, When a wifi is connected the Mobile Network Connections are automatically disabled in Android, so if you check the status of 3G it will be disconnected only. You don't need to do this programmatically, it is already present in Android System.

Even though in the Navigation panel you may see 3G enabled, but it is not ON simultaneously with WiFi.

Vedang Jadhav
  • 510
  • 2
  • 11
  • Well, it is not on simultaneously with Wifi, but when both enabled then when the device is sleeping (the screen is off) then the Wifi is disabled and the 3G is on as you can read in the link I provided – adl Aug 23 '13 at 10:15