0

Possible Solutions here : How to disable Mobile Data on Android

In http://developer.android.com/reference/android/net/ConnectivityManager.html we see how we can query different network availability. is there a way to tell the device to not use GPRS/ other data?

Want a way to do what happens in the settings/Wireless and networks/Mobile networks when you toggle 'Use packet data'


Want API to disable the cellular one, not the WIFI. WIFI is already off. Want it to remain off. goal is to give a quicker UI to switch 'Use packet data' off and on, without changing anything else via my application which the user can keep a shortcut too or configure to switch of packet data at certain times of the day or under other conditions

Community
  • 1
  • 1
tgkprog
  • 4,493
  • 4
  • 41
  • 70

1 Answers1

1

If the wifi connection is established, it will get precedence over cellular networks like 2G and 3G. Once the wifi connection is broken, the android system will look for cellular connection if it is enabled and connected.

You can use the following code to disable/enable wifi adapter on the android

private void networkChangeTest() {

    if(wifiManager.isWifiEnabled()) {
        wifiManager.setWifiEnabled(false);
    } else wifiManager.setWifiEnabled(true);

}

If the wifi is enabled it will be switched off and if it is enabled, it will be switched on. When the wifi is disabled, the android system will automatically shift to cellular data connection.

Only one data connection(wifi/cellular) can be active at one time on the android system.

Update :

This link shows how to enable/disable packet(cellular) data option : How to disable Mobile Data on Android

Community
  • 1
  • 1
Srikant Sahay
  • 885
  • 6
  • 9
  • i want to disable the cellular one, not the WIFI. WIFI is off. Want it to remain off. I goal is to give a quicker UI to switch it off and on, without changing anything else – tgkprog Jun 04 '13 at 11:49
  • 1
    Try http://stackoverflow.com/questions/3644144/how-to-disable-mobile-data-on-android .Haven't tried this myself but you can check if it works for you. – Srikant Sahay Jun 04 '13 at 11:55