/*** @ Author stay * determine the mobile operator */public class networkoperater extends activity {Private Static final string tag = "mainactivity";/** called when the activity is first created. * // @ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); connectivitymanager connec = (connectivitymanager) getsystemservice (context. connectivity_service); // If (Connec. getnetworkinfo (connectivitymanager. type_wifi ). getstate () = networkinfo. state. connected) // wifimanager = (wifimanager) This. getsystemservice (context. wifi_service); // networkinfo info1 = connec. getnetworkinfo (connectivitymanager. type_wifi); // If (info1.isconnectedorconnecting () {// wifimanager. setwifienabled (false); //} // log. I (TAG, // "getdetailedstate =" + info1.getdetailedstate () +" \ N "+ //" getreason = "+ info1.getreason () +" \ n "+ //" getsubtype = "+ info1.getsubtype () + "\ n" + // "getsubtypename =" + info1.getsubtypename () + "\ n" + // "getextrainfo =" + info1.getextrainfo () + "\ n" + // "gettypename =" + info1.gettypename () + "\ n" + // "GetType =" + info1.gettype () + "\ n" //); // determine networkinfo info2 = connec through networking. getnetworkinfo (connectivitymanager. type_mobile); log. I (TAG, "getdetailedstate =" + Info2.getdetailedstate () + "\ n" + "getreason =" + info2.getreason () + "\ n" + "getsubtype =" + info2.getsubtype () + "\ n" + "getsubtypename =" + info2.getsubtypename () + "\ n" + "getextrainfo =" + info2.getextrainfo () + "\ n" + "gettypename =" + info2.gettypename () + "\ n" + "GetType =" + info2.gettype ()); // determine telephonymanager telmanager = (telephonymanager) getsystemservice (context. telephony_service );/** Obtain the SIM card's imsi Code * unique SIM card ID: imsi International Mobile User identification code (imsi: International Mobile Subscriber identification number) is a different sign for mobile users, * stored in the SIM card, it can be used to differentiate valid information of mobile users. Imsi consists of MCC, MNC, and msin. Among them, MCC is a mobile country number consisting of three digits. * It uniquely identifies the country to which mobile customers belong, and China is 460; MNC is a network ID consisting of two digits. * It is used to identify the mobile network to which a mobile customer belongs. China Mobile is 00, China Unicom is 01, and China Telecom is 03; msin is a mobile customer identification code consisting of 11 digits. * Uniquely identifies China Mobile clients in the domestic GSM mobile communication network. To distinguish between mobile and Unicom, you only need to obtain the MNC field in the SIM card */string imsi = telmanager. getsubscriberid (); "getnetworkoperatorname =" + telmanager. getnetworkoperatorname () + "\ n" + // get the Mobile Operator name directly
If (imsi! = NULL) {If (imsi. startswith ("46000") | imsi. startswith ("46002") | imsi. startswith ("46007") {// because imsi under mobile network number 46000 is used up, A 46002 number is virtualized, section 134/159 uses this ID // China Mobile} else if (imsi. startswith ("46001") {// China Unicom} else if (imsi. startswith( "46003 ")) {// China Telecom }}/ *** @ author stay * when the network connection mode is changed */private class connectionchangereceiver extends broadcastreceiver {@ overridepublic void onreceive (context, intent I Ntent) {connectivitymanager = (connectivitymanager) context. getsystemservice (context. connectivity_service); networkinfo activenetinfo = connectivitymanager. getactivenetworkinfo (); networkinfo mobnetinfo = connectivitymanager. getnetworkinfo (connectivitymanager. type_mobile); If (activenetinfo! = NULL) {toast. maketext (context, "active network type:" + activenetinfo. gettypename (), Toast. length_short). Show ();} If (mobnetinfo! = NULL) {toast. maketext (context, "mobile network type:" + mobnetinfo. gettypename (), toast. length_short ). show () ;}}/* China Unicom 3G card WAP interconnect 03-16 16:09:14. 754: INFO/mainactivity (977): getdetailedstate = CONNECTED03-16 16:09:14. 754: INFO/mainactivity (977): getreason = apnChanged03-16 16:09:14. 754: INFO/mainactivity (977): getsubtype = 803-16 16:09:14. 754: INFO/mainactivity (977): getsubtypename = HSDPA03-16 16:09:14. 754: INFO/mainactivity (977): getextrainfo = uniwap03-16 16:09:14. 754: INFO/mainactivity (977): gettypename = mobile03-16 16:09:14. 754: INFO/mainactivity (977): GetType = 0 * // * China Unicom 3G card 3G connection 03-16 16:13:48. 314: INFO/mainactivity (1522): getdetailedstate = CONNECTED03-16 16:13:48. 314: INFO/mainactivity (1522): getreason = apnSwitched03-16 16:13:48. 314: INFO/mainactivity (1522): getsubtype = 303-16 16:13:48. 314: INFO/mainactivity (1522): getsubtypename = UMTS03-16 16:13:48. 314: INFO/mainactivity (1522): getextrainfo = painet03-16 16:13:48. 314: INFO/mainactivity (1522): gettypename = mobile03-16 16:13:48. 314: INFO/mainactivity (1522): GetType = 0 * // * Mobile WAP connection 03-16 16:20:39. 295: INFO/mainactivity (734): getdetailedstate = CONNECTED03-16 16:20:39. 295: INFO/mainactivity (734): getreason = apnChanged03-16 16:20:39. 295: INFO/mainactivity (734): getsubtype = 203-16 16:20:39. 295: INFO/mainactivity (734): getsubtypename = EDGE03-16 16:20:39. 295: INFO/mainactivity (734): getextrainfo = cmwap03-16 16:20:39. 295: INFO/mainactivity (734): gettypename = mobile03-16 16:20:39. 295: INFO/mainactivity (734): GetType = 0 * // * Mobile net connection 03-16 16:23:34. 045: INFO/mainactivity (734): getdetailedstate = CONNECTED03-16 16:23:34. 045: INFO/mainactivity (734): getreason = apnSwitched03-16 16:23:34. 045: INFO/mainactivity (734): getsubtype = 203-16 16:23:34. 045: INFO/mainactivity (734): getsubtypename = EDGE03-16 16:23:34. 045: INFO/mainactivity (734): getextrainfo = cmnet03-16 16:23:34. 045: INFO/mainactivity (734): gettypename = mobile03-16 16:23:34. 045: INFO/mainactivity (734): GetType = 0/Telecom 05-25 18:55:30. 180: INFO/mainactivity (731): getdetailedstate = DISCONNECTED05-25 18:55:30. 180: INFO/mainactivity (731): getreason = dataDisabled05-25 18:55:30. 180: INFO/mainactivity (731): getsubtype = 605-25 18:55:30. 180: INFO/mainactivity (731): getsubtypename = CDMA-evdo rev. a05-25 18:55:30. 180: INFO/mainactivity (731): getextrainfo = #77705-25 18:55:30. 180: INFO/mainactivity (731): gettypename = MOBILE05-25 18:55:30. 180: INFO/mainactivity (731): GetType = 0 */}