Android Get SIM card operator information (GO)

Source: Internet
Author: User

Telephonymanager TM = (Telephonymanager) context.getsystemservice (Context.telephony_service);

Note: Some phone messages require the appropriate permissions.

Get the name of the service provider, such as Telecom, Unicom, mobile The first method is to obtain the IMSI code of the mobile phone, and to judge that it is China Mobile Unicom Telecom

Getsimoperatorname ()  //Returns the Service Provider Name (SPN). 

IMSI International Mobile Subscriber Identification Number (imsi:international Mobile subscriber identification number) is a sign that distinguishes a mobile user and is stored in a SIM card that can be used to differentiate valid information from a mobile user.

IMSI consists of MCC, MNC, Msin,

MCC is a mobile country number, consisting of 3 digits//uniquely identify the country to which the mobile customer belongs, our country is 460;

MNC for the network ID, composed of 2 digits//used to identify mobile customers belong to the mobile network, China Mobile is 00, Unicom is 01, Chinese telecom for 03;

Msin for mobile Customer identification Code, the use of equal length of 11 digits//Uniquely identify the domestic GSM mobile communication network to move customers.

It can be seen that imsi in the min number before the MCC, can distinguish each user from the country, so can achieve international roaming.

In the same country, if there are multiple CDMA operators, the MNC can be used to differentiate.

So to distinguish between mobile or unicom, just get the MNC field in the SIM card

String IMSI = Telmanager.getsubscriberid ();

if (Imsi!=null) {

if (Imsi.startswith ("46000″) | | Imsi.startswith ("46002″)"

{

// Because the mobile network number 46000 under the IMSI has been exhausted, so virtual a 46002 number, 134/159th segment used this number // China Mobile

}else Span style= "color: #0000ff;" >if (Imsi.startswith ("46001″) {

// China Unicom

}else if (Imsi.startswith ("46003″") {

// China Telecom

}

} /span>

The second method of

Telephonymanager Telmanager = (telephonymanager) getsystemservice (Context.telephony_service);

String operator = Telmanager.getsimoperator ();

if (operator!=null) {

if (Operator.equals ("46000″) | | Operator.equals ("46002″) | | Operator.equals ("46007″)") {

China Mobile

}Else if (operator.equals ("46001″)") {

China Unicom

}Else if (operator.equals ("46003″)") {

China Telecom

}

}

Add permissions in file Androidmanifest.xml Other ways to use this method please see the instructions in the API documentation Telephonymanager.

Add permissions in file Androidmanifest.xml <uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>

Function description

Getcelllocation () returns the cell position of the appliance access_coarse_location or access_fine_location

Getdeviceid () returns the Imei/meid device. If the device is a GSM device then the IMEI number will be returned if the device is a CDMA device then Meid will be returned read_phone_state

Getline1number () returns the phone number of the device (MSISDN number) read_phone_state

Getnetworkoperatorname () returns the name of the registered network operator

Getnetworkoperator () back to MCC + registered network operator of multinational companies

Getnetworkcountryiso () returns the country code of the registered network operator

Getsimcountryiso () returns the SIM card operator's country code read_phone_state

Getsimoperator () returns the number of individual nuclear cells of the SIM card operator + metallurgical read_phone_state

Getsimoperatorname () returns the name of the SIM card operator Read_phone_state

Getsimserialnumber () returns the serial number of the SIM card read_phone_state

Getnetworktype () returns the type of network device available. This will be one of the following values:

Telephonymanager.network_type_unknown

Telephonymanager.network_type_gprs

Telephonymanager.network_type_edge

Telephonymanager.network_type_umts read_phone_state

Getphonetype () returns the type of the device.

This will be one of the following values:

Telephonymanager.phone_type_none

telephonymanager.phone_type_gsm

TELEPHONYMANAGER.PHONE_TYPE_CDMA read_phone_state

Getsubscriberid () returns the device of the user ID (IMSI) read_phone_state

Getneighboringcellinfo () Returns the information of the Neighboringcellinfo class representing the neighboring cell, or returns NULL if available Access_coarse_updates

Android Get SIM card operator information (GO)

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.