Android gets IMSI information (judging is mobile, Unicom, Telecom Mobile card)

Source: Internet
Author: User

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)

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.