Looking For The Android.net.iconnectivitymanager
Solution 1:
Should i just forget about it ( I don't want to ) or is there a way to get this class?
A standard SDK application cannot hold the permission needed to change the background data setting. Hence, whether you can get to this class or not is probably immaterial.
Solution 2:
You can get the instance of iConnectivityManager via ConnectivityManager see below how :-
finalConnectivityManagerconman= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Class conmanClassconmanClass= Class.forName(conman.getClass().getName());
final java.lang.reflect.FieldiConnectivityManagerField= conmanClass.getDeclaredField("mService");
iConnectivityManagerField.setAccessible(true);
finalObjectiConnectivityManager= iConnectivityManagerField.get(conman);
finalClassiConnectivityManagerClass= Class.forName(iConnectivityManager.getClass().getName());
Now, you can call any method or field from this class, actually this class no longer exist but this is the backdoor way of accessing this class, for eg. you want to access the any method from this class say setMobileDataEnabledMethod(),
so
final Method setMobileDataEnabledMethod = iConnectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
similarly any other field,
final java.lang.reflect.FieldiConnectivityManagerField= iConnectivityManagerClass.getDeclaredField("xyz");
i hope this will clear query leave your comments for more...
Post a Comment for "Looking For The Android.net.iconnectivitymanager"