CoreCode:
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
-
- /**
-
- *
-
- *
-
- * Creation date: 05:02:47
-
- *
-
- */
- PackageNet. sunniwell. app;
-
- ImportAndroid. App. activity;
-
- ImportAndroid. OS. Bundle;
-
- ImportAndroid. telephony. celllocation;
-
- ImportAndroid. telephony. phonestatelistener;
-
- ImportAndroid. telephony. telephonymanager;
- Public ClassTelmanagerExtendsActivity {
-
-
- @ Override
-
- Protected VoidOncreate (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 disconnect
-
- */
-
- TM. getcallstate ();// Int
-
-
- /*
-
- * Phone location:
-
- *
-
- */
- TM. getcelllocation ();// Celllocation
-
-
- /*
-
- * Unique device ID:
-
- * The IMEI of the GSM mobile phone and the meid of the CDMA mobile phone.
-
- * Return NULL if device ID is not 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 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 <neighboringcellinfo>
-
-
- /*
-
- * 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
-
-
- /*
-
- * The Name Of The current registered operator (currently registered user) in alphabetical order
-
- * Note: it is valid only when the user has registered the network.
-
- * The results may be unreliable in CDMA networks.
-
- */
- TM. getnetworkoperatorname ();// String
-
-
- /*
-
- * Current network type:
-
- * For example, The network_type_unknown network type is unknown. 0
-
- Network_type_gprs GPRS network 1
- Network_type_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 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 has 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. 5 or 6-digit decimal number provided by the SIM card.
- * 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:
-
- * Permission required: read_phone_state
- */
-
- TM. getsimserialnumber ();// String
-
-
- /*
-
- * Sim status information:
-
- * Sim_state_unknown unknown status 0
- Sim_state_absent no card 1
-
- Sim_state_pin_required lock status, which requires the user's pin code to be unlocked 2
-
- Sim_state_puk_required lock status, which requires the user's pukcode to be unlocked 3
-
- Sim_state_network_locked lock status, which requires the network pin to be unlocked 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
-
-
- /*
-
- * Obtain the tags related to the voice mail, that is, the identifier.
-
- * Permission required: read_phone_state
-
- */
- TM. getvoicemailalphatag ();// String
-
-
- /*
-
- * Obtain the voice mail Number:
-
- * Permission required: read_phone_state
-
- */
-
- TM. getvoicemailnumber ();// String
-
- /*
-
- * Whether the ICC card exists
-
- */
-
- TM. hasicccard ();// Boolean
-
-
- /*
-
- * Roaming or not:
-
- * (For GSM purposes)
- */
-
- TM. isnetworkroaming ();//
-
-
-
-
- }
-
-
-
- }
-
- TransferHttp://blog.csdn.net/gumanren/archive/2011/02/26/6209237.aspx