First we need to know mobile phone IMSI number 3 bits 460 is the country, followed by 2 bits 00 02 is China Mobile, 01 is China Unicom, 03 is Chinese telecom. So the first step is to get the phone IMSI number: The code is as follows
1 /**2 * Get IMSI information3 * @paramContext4 * @return5 */6 Public StaticString Getphoneimsi (context context) {7Telephonymanager mtelephonymgr =(telephonymanager) Context8 . Getsystemservice (context.telephony_service);9LOG.V ("LJC", "Get Getsubscriberid" +Mtelephonymgr.getsubscriberid ());Ten returnMtelephonymgr.getsubscriberid (); One}
Or:
1 /**2 * Check if Telecom Mobile card3 * 4 * @returnThe Telco card returns true otherwise false5 */6 Public BooleanChecksimcarl (Context context) {7 BooleanValue =false;8String IMSI =Getphoneimsi (context);9 if(IMSI! =NULL) {Ten if(Imsi.startswith ("46003")) OneValue =true; A } - returnvalue; - //IMSI Front 3 bit 460 is the country, followed by 2 bit 00 02 is China Mobile, 01 is China Unicom, 03 is Chinese telecom. Which the //if (Imsi.startswith ("46000") | | Imsi.startswith ("46002")) { - //providersname = "China Mobile"; - //} else if (Imsi.startswith ("46001")) { - //providersname = "China Unicom"; + //} else if (Imsi.startswith ("46003")) { - //providersname = "China Telecom"; +}
Android gets IMSI information (judging is mobile, Unicom, Telecom Mobile card)