Android gets the IMEI number

Source: Internet
Author: User

Core code:

IMEI = (telephonymanager) getsystemservice (telephony_service). getdeviceid ();

1. Add Permissions

In the manifest. xml file, add <uses-Permission Android: Name = "android. Permission. read_phone_state"/>

2. Code

/***** Author test * created on 05:02:47 **/package net. sunniwell. APP; import android. app. activity; import android. OS. bundle; import android. telephony. celllocation; import android. telephony. phonestatelistener; import android. telephony. telephonymanager; public class telmanager extends activity {@ override protected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); Telephonymanager TM = (telephonymanager) This. getsystemservice (telephony_service);/** call status: * 1. TM. call_state_idle = 0 no activity * 2. TM. call_state_ringing = 1 bell * 3. TM. call_state_offhook = 2 disconnect */TM. getcallstate (); // int/** phone location: **/TM. getcelllocation (); // celllocation/** unique device ID: * IMEI of the GSM mobile phone and meid of the CDMA mobile phone. * return NULL if device ID is not available. */TM. getdeviceid (); // string/** Software Version :* For example, the IMEI/SV (Software Version) for GSM phones. * return NULL if the software version is not available. */TM. getdevicesoftwareversion (); // string/** mobile phone number: * msisdn of the GSM mobile phone. * return NULL if it is unavailable. */TM. getline1number (); // string/** nearby phone information: * type: List <neighboringcellinfo> * permission required: Android. manifest. permission # access_coarse_updates */TM. getneighboringcellinfo (); // list <neighboringcelli Nfo>/** obtain the ISO Standard Country Code, that is, the international long-distance area code. * Note: it is valid only after the user has registered the network. * The results may be unreliable in CDMA networks. */TM. getnetworkcountryiso (); // string/** MCC + MNC (mobile country code + mobile network code) * Note: it is valid only when the user has registered the network. * The results may be unreliable in CDMA networks. */TM. getnetworkoperator (); // string/** name of the current registered operator (currently registered user) in alphabetical order * Note: this parameter is valid only when the user is registered on the network. * The results may be unreliable in CDMA networks. */TM. getnetworkoperatorname (); // string/** current network type used: * example: unknown network type 0 network_type_gprs GPRS network 1 network_type_edge Network 2 network_type_umts UMTS network 3 hybrid HSDPA network 8 hybrid hsupa network 9 network_type_hspa HSPA network 10 network_type_cdma network, is95a or is95b. 4 network_type_evdo_0 evdo network, Revision 0. 5 network_type_evdo_a evdo network, Revision. 6 network_type_1x RTT 1xrtt network 7 */TM. getnetworktype (); // int/** mobile phone type: * e. g.: phone_type_none no signal phone_type_gsm GSM signal phone_type_cdma signal */TM. getphonetype (); // int/** returns the ISO country code equivalent for the sim provider's country code. * obtain the ISO country code, which is equivalent to the Country Code that provides the SIM card. **/TM. getsimcountryiso (); // string/** returns the MCC + MNC (mobile country code + mobile network code) of the provider of the sim. 5 or 6 decimal digits. * obtain the mobile country code and mobile network code provided by the SIM card. 5 or 6 digits in decimal format. * The SIM card status must be sim_state_ready (determined by getsimstate ). */TM. getsimoperator (); // string/** service provider name: * For example, China Mobile and China Unicom * the SIM card status must be sim_state_ready (determined by getsimstate ). */TM. getsimoperatorname (); // string/** SIM card serial number: * required permission: read_phone_state */TM. getsimserialnumber (); // string/** SIM status information: * sim_state_unknown unknown status 0 sim_state_absent no plug-in card 1 sim_state_pin_required lock status. the user's pin code is required to unlock 2 Tib lock status, the user's pukcode is required to unlock the 3 sim_state_network_locked lock status, and the network's pin code is required to unlock 4 sim_state_ready ready status 5 */TM. getsimstate (); // int/** Unique User ID: * For example, imsi (International Mobile User Identification Code) for a gsm phone. * permission required: read_phone_state */TM. getsubscriberid (); // string/** get the tags related to the voice mail, that is, the identifier * requires the permission: read_phone_state */TM. getvoicemailalphatag (); // string/** get the voice mail number: * permission required: read_phone_state */TM. getvoicemailnumber (); // string/** check whether the ICC card exists */TM. hasicccard (); // Boolean/** roaming: * (for GSM purposes) */TM. isnetworkroaming ();//}}

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.