2011-03-17 5 views
0

가능한 중복 :
How to disable Mobile Data on AndroidAndroid에서 3g 데이터 서비스를 사용/사용 중지하는 방법은 무엇인가요?

나는 처음에 3G 데이터 서비스를 활성화 필요 안드로이드에 대한 AAP를 확인해야합니다. 예를 들어 설정 값을 변경하는 여러 가지 방법을 알려주십시오. adb 쉘 명령 또는 API/라이브러리를 사용할 수 있습니다. 예제에 대한 링크가 더 유용 할 것입니다.

미리 감사드립니다.

답변

1

감사

발견 대답 유래 stackoverflow.com하기 : How to disable Mobile Data on Android

Method dataConnSwitchmethod; 
Class telephonyManagerClass; 
Object ITelephonyStub; 
Class ITelephonyClass; 

TelephonyManager telephonyManager = (TelephonyManager) context 
     .getSystemService(Context.TELEPHONY_SERVICE); 

if(telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED){ 
    isEnabled = true; 
}else{ 
    isEnabled = false; 
} 

telephonyManagerClass = Class.forName(telephonyManager.getClass().getName()); 
Method getITelephonyMethod = telephonyManagerClass.getDeclaredMethod("getITelephony"); 
getITelephonyMethod.setAccessible(true); 
ITelephonyStub = getITelephonyMethod.invoke(telephonyManager); 
ITelephonyClass = Class.forName(ITelephonyStub.getClass().getName()); 

if (isEnabled) { 
    dataConnSwitchmethod = ITelephonyClass 
      .getDeclaredMethod("disableDataConnectivity"); 
} else { 
    dataConnSwitchmethod = ITelephonyClass 
      .getDeclaredMethod("enableDataConnectivity"); 
} 
dataConnSwitchmethod.setAccessible(true); 
dataConnSwitchmethod.invoke(ITelephonyStub); 
관련 문제