have a look at line 791/ 792 ;-) Gl http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.1_r2/android/telephony/TelephonyManager.java?av=f
Op dinsdag 31 juli 2012 17:03:13 UTC+2 schreef CJ het volgende: > > Hi, > > I have been googling for a while able the best or right way to > disable/enable mobile network. > > I tried the following code which is all over Stackoverflow and is working > fine for gingerbread and higher: > > private void setMobileDataEnabled(Context context, boolean enabled) > throws Exception { > final ConnectivityManager conman = (ConnectivityManager) context > .getSystemService(Context.CONNECTIVITY_SERVICE); > final Class<?> conmanClass = Class.forName(conman.getClass().getName()); > final Field iConnectivityManagerField = conmanClass > .getDeclaredField("mService"); > iConnectivityManagerField.setAccessible(true); > final Object iConnectivityManager = iConnectivityManagerField > .get(conman); > final Class<?> iConnectivityManagerClass = Class > .forName(iConnectivityManager.getClass().getName()); > final Method setMobileDataEnabledMethod = iConnectivityManagerClass > .getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE); > setMobileDataEnabledMethod.setAccessible(true); > > setMobileDataEnabledMethod.invoke(iConnectivityManager, enabled); > } > > Somehow I didn't find a way to do the same thing for Android 2.2 and > below. Many mentioned to change the APN name to something invalid like what > app APNDroid did but is that the only way? > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en