Judgment SIM card belongs to which mobile operators

The first method :

Get phone IMSI code , and judgment is China Mobile \ China Unicom \ China Telecom

TelephonyManager telManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

        / ** Gets SIM card IMSI code

         * The SIM card that uniquely identifies: IMSI international mobile subscriber identity ( IMSI : InternationalMobile up for Subscriber Identification Number The ) is the difference between a mobile user's logo,

         * Stored in the SIM card, it can be used to distinguish valid information of mobile user. IMSI from the MCC , the MNC , the MSIN , where MCC is a Mobile Country Code, a . 3 digits,

         * Uniquely identify the country belongs to mobile customers, our country was 460 ; MNC for the network the above mentioned id , the 2 digits,

         * Mobile network to identify the mobile client belongs, China Mobile is 00 , China Unicom is 01, China Telecom is 03 ; MSIN mobile customer identification code, as long as the use of 11 -bit digital constituted.

         * Uniquely identify domestic GSM mobile communication network mobile customers. So to distinguish between mobile or Unicom, just get SIM card MNC field to

         */

        Stringimsi = telManager.getSubscriberId();

 if(imsi!=null){

       if (imsi.startsWith ( "46000") || imsi.startsWith ( "46002")) {// since the mobile network number 46000 under the IMSI it has been used up, so that a virtual 46002 number 134/159 number of segments used this number

         // China Mobile

        }elseif(imsi.startsWith("46001")){

         // China Unicom

        }elseif(imsi.startsWith("46003")){

         // China Telecom

        }

}

The second method

TelephonyManager telManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

        Stringoperator = telManager.getSimOperator();

 if(operator!=null){

       if(operator.equals("46000") ||operator.equals("46002")){

         // China Mobile

        }elseif(operator.equals("46001")){

         // China Unicom

        }elseif(operator.equals("46003")){

         // China Telecom

        }

}

Reproduced in: https: //my.oschina.net/u/936286/blog/542017

Guess you like

Origin blog.csdn.net/weixin_33859665/article/details/92025731