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