Android gets the mobile phone IMSI number

Source: Internet
Author: User

Android gets the mobile phone IMSI number

1. What is imsi?

The IMSI (International Mobile SubscriberIdentification Number) identifies different Mobile users. It is stored in SIM cards and can be used to distinguish valid information of Mobile users. The total length is no more than 15 characters, and 0 ~ 9. Among them, MCC is the country code of the mobile user, which accounts for three digits. China's MCC stipulates that it is 460. MNC is a mobile network number, which consists of up to two digits, MSIN is a mobile user identification code used to identify the mobile users in a mobile communication network.

MNC: Mobile Network Code, Mobile Network Code, 2 ~ The China Mobile system uses 00, 02, and 07, China Unicom's GSM system uses 01, China Telecom's CDMA system uses 03, and a typical IMSI number is 460030912121001;

2. Get the mobile phone imsi number

Public static String getImsi (Context context ){
TelephonyManager tm = (TelephonyManager) context. getSystemService (Context. TELEPHONY_SERVICE );
String _ imsi = tm. getSubscriberId ();
If (_ imsi! = Null &&! _ Imsi. equals ("") {
Return _ imsi;
}
Return "unknown ";
}

3,

Public static String getImsi (Context context ){
TelephonyManager tm = (TelephonyManager) context
. GetSystemService (Context. TELEPHONY_SERVICE );
String deviceid = tm. getDeviceId (); // obtain the unique ID of a smart device.
String te1 = tm. getLine1Number (); // obtain the local number
String imei = tm. getSimSerialNumber (); // obtain the serial number of the SIM card
String imsi = tm. getSubscriberId (); // obtain the user ID
If (imsi! = Null &&! Imsi. equals ("")){
Log. I ("test", "Get mobile phone information === Deviceid" + deviceid + "teleNum" + te1
+ "SimNUM" + imei + "UserId" + imsi );
Return imsi;
}
Return "unknown ";
}

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.