The method of acquiring IMEI code in Android _android

Source: Internet
Author: User
Core code:
Imei = ((Telephonymanager) Getsystemservice (Telephony_service))
. Getdeviceid ();
1. Permission to join
To add <uses-permission android:name= "Android.permission.READ_PHONE_STATE" in the Manifest.xml file/>
2. Code
Copy Code code as follows:

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);

/*
* Phone Status:
* 1.tm. Call_state_idle=0 No Activity
* 2.tm. Call_state_ringing=1 Bell
* 3.tm. Call_state_offhook=2 Picking Machine
*/
Tm.getcallstate ();//int

/*
* Phone Location:
*
*/
Tm.getcelllocation ();//celllocation

/*
* Unique Device ID:
* GSM mobile phone IMEI and CDMA mobile phone MEID.
* Return NULL if Device ID isn't available.
*/
Tm.getdeviceid ();//string

/*
* Software version number of the device:
* For example: The IMEI/SV (software version) for GSM phones.
* Return NULL if the software version are not available.
*/
Tm.getdevicesoftwareversion ();//string

/*
* Mobile phone Number:
* GSM mobile phone's MSISDN.
* Return NULL if it is unavailable.
*/
Tm.getline1number ();//string

/*
* Information about the telephone nearby:
* Type:list<neighboringcellinfo>
* Need permission: Android. Manifest.permission#access_coarse_updates
*/
Tm.getneighboringcellinfo ();//list<neighboringcellinfo>

/*
* Obtain the ISO standard country code, namely the international long-distance code.
* Note: Only if the user has been registered with the network.
* Results may be unreliable in CDMA networks.
*/
Tm.getnetworkcountryiso ();//string

/*
* MCC+MNC (Mobile Country code + mobile network Code)
* Note: Valid only if the user is already registered on the network.
* Results may be unreliable in CDMA networks.
*/
Tm.getnetworkoperator ();//string

/*
* Name of current registered operator (currently registered user) in alphabetical order
* Note: Valid only if the user is already registered on the network.
* Results may be unreliable in CDMA networks.
*/
Tm.getnetworkoperatorname ();//string

/*
* The type of network currently in use:
* For example: Network_type_unknown network type unknown 0
Network_type_gprs GPRS Network 1
Network_type_edge EDGE Network 2
NETWORK_TYPE_UMTS UMTS Network 3
NETWORK_TYPE_HSDPA HSDPA Network 8
Network_type_hsupa HSUPA Network 9
Network_type_hspa HSPA Network 10
NETWORK_TYPE_CDMA CDMA Network, is95a or is95b. 4
NETWORK_TYPE_EVDO_0 EVDO Network, Revision 0. 5
Network_type_evdo_a EVDO Network, revision A. 6
Network_type_1xrtt 1xRTT Network 7
*/
Tm.getnetworktype ();//int

/*
* Mobile Phone Type:
* For example: Phone_type_none no signal
PHONE_TYPE_GSM GSM Signal
PHONE_TYPE_CDMA 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 providing the SIM card country code.
*
*/
Tm.getsimcountryiso ();//string

/*
* Returns the MCC+MNC (mobile Country code + mobile Network Code) of the provider of the SIM. 5 or 6 decimal digits.
* Get the Mobile country Code and mobile network code. 5 or 6 decimal digits provided by the SIM card.
* The status of the SIM card must be Sim_state_ready (using getsimstate () to judge).
*/
Tm.getsimoperator ();//string

/*
* Service Provider Name:
* For example: China Mobile, Unicom
* The status of the SIM card must be Sim_state_ready (using getsimstate () to judge).
*/
Tm.getsimoperatorname ();//string

/*
* The serial number of the SIM card:
* Need permission: Read_phone_state
*/
Tm.getsimserialnumber ();//string

/*
* Status information for SIM:
* Sim_state_unknown Unknown State 0
Sim_state_absent, no card 1.
Sim_state_pin_required lock state, requires the user's PIN code unlock 2
Sim_state_puk_required lock state, requires the user's PUK code unlock 3
sim_state_network_locked lock state, requires the network PIN code 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.
* Need permission: Read_phone_state
*/
Tm.getsubscriberid ();//string

/*
* Get the label associated with the voice mail, that is, the identifier
* Need permission: Read_phone_state
*/
Tm.getvoicemailalphatag ();//string

/*
* Get voice mail number:
* Need permission: Read_phone_state
*/
Tm.getvoicemailnumber ();//string

/*
* Whether the ICC card exists
*/
Tm.hasicccard ();//boolean

/*
* Whether to roam:
* (under the GSM use)
*/
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.