This article illustrates the usage of the Android network data switch. Share to everyone for your reference, specific as follows:
This part of the interface is not open in the API. So you can use this method, true to turn on, false to close. Currently on the G-Net mobile phone can.
Public Boolean setmobiledataenabled (Boolean enabled) {
final telephonymanager Mtelmanager;
Mtelmanager = (Telephonymanager) getsystemservice (context.telephony_service);
Try {method
m = Mtelmanager.getclass (). Getdeclaredmethod ("Getitelephony"); M.setaccessible (true)
; Object telephony = M.invoke (Mtelmanager);
m = Telephony.getclass (). GetMethod (enabled? "Enable": "Disable") + "dataconnectivity");
M.invoke (telephony);
return true;
} catch (Exception e) {
log.e ("", "cannot fake telephony", e);
return false;
}
}
For more information on Android-related content readers can view the site topics: "Android Database Operating skills summary", "Android programming activity Operation Skills Summary", "Android File Operation skills Summary", " Android programming development of the SD card operation method Summary, "Android Development introduction and Advanced Course", "Android Resource Operation skills Summary", "Android View tips Summary" and "Android Control usage Summary"
I hope this article will help you with the Android program.