0

how can I disable and enable the mobile data(3G) on Android?

I read that I need to use the connectivity manager. However, I still don't understand how I can enable and disable the mobile data?

I found this, however, it doesn't work for me,

Can anyone explain me what can I do to turn on and off the mobile data?

TelephonyManager telephonyManager = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
switch (telephonyManager.getDataState()) {
        case TelephonyManager.DATA_CONNECTED:
            setMobileDataEnabledMethod.invoke(iConnectivityManager, false);
            break;
        case TelephonyManager.DATA_DISCONNECTED:
            setMobileDataEnabledMethod.invoke(iConnectivityManager, true);
            break;
        }
Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151
fsdf fsd
  • 1,301
  • 4
  • 13
  • 13

1 Answers1

0

How to disable Mobile Data on Android

Against which api level are you developing? Logcat as Siddharth suggest ... Too less informations top help you appropriate

Community
  • 1
  • 1
DieselPower
  • 738
  • 2
  • 6
  • 22