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;
}