Android obtains IMSI information (determined to be mobile, Unicom, and Telecom mobile phone cards) and androidimsi

Source: Internet
Author: User

Android obtains IMSI information (determined to be mobile, Unicom, and Telecom mobile phone cards) and androidimsi

First, we need to know that the first three digits of the mobile phone IMSI number are China Mobile, followed by two digits of 00 02, 01 is China Unicom, and 03 is China Telecom. The first step is to obtain the mobile phone IMSI number first: the code is as follows:

1/** 2 * Get IMSI Information 3 * @ param context 4 * @ return 5 */6 public static String getPhoneIMSI (Context context) {7 TelephonyManager mTelephonyMgr = (TelephonyManager) context 8. getSystemService (Context. TELEPHONY_SERVICE); 9 Log. v ("LJC", "get getSubscriberId" + mTelephonyMgr. getSubscriberId (); 10 return mTelephonyMgr. getSubscriberId (); 11}

Or:

 

1/** 2 * check whether the telecom phone card is 3*4 * @ return: return true; otherwise, false 5 */6 public boolean checkSIMCarl (Context context) {7 boolean value = false; 8 String IMSI = getPhoneIMSI (context); 9 if (IMSI! = Null) {10 if (IMSI. startsWith ("46003") 11 value = true; 12} 13 return value; 14 // the first three digits of IMSI are countries, followed by two digits of 00 02 are China Mobile, 01 is China Unicom and 03 is China Telecom. 15 // if (IMSI. startsWith ("46000") | IMSI. startsWith ("46002") {16 // ProvidersName = "China Mobile"; 17 //} else if (IMSI. startsWith ("46001") {18 // ProvidersName = "China Unicom"; 19 //} else if (IMSI. startsWith ("46003") {20 // ProvidersName = "China Telecom"; 21}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.