How to disable Mobile Data on Android

后端 未结 8 1973
予麋鹿
予麋鹿 2020-11-22 12:13

Quick back story before someone tells me to buy an app. =)

I just got an EVO and it chews through the battery fairly quick. I downloaded JuiceDefender to manage

8条回答
  •  佛祖请我去吃肉
    2020-11-22 12:32

    to add a toggle button you can use this code in addition Vladimir's Answer:

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

    This reflection workaround is still working for me on android 4.0.4

提交回复
热议问题