Android get IMEI number

Source: Internet
Author: User

Core code:

Imei = ((Telephonymanager) Getsystemservice (Telephony_service))
. Getdeviceid ();

1. Permission to join

In the Manifest.xml file, add <uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>

2. Code

  1. /**
  2. *
  3. *
  4. * Created on 2010-4-29 05:02:47
  5. *
  6. */
  7. Package Net.sunniwell.app;
  8. Import android.app.Activity;
  9. Import Android.os.Bundle;
  10. Import android.telephony.CellLocation;
  11. Import Android.telephony.PhoneStateListener;
  12. Import Android.telephony.TelephonyManager;
  13. Public class Telmanager extends Activity {
  14. @Override
  15. protected void OnCreate (Bundle savedinstancestate) {
  16. super.oncreate (savedinstancestate);
  17. Telephonymanager TM = (Telephonymanager) this.getsystemservice (Telephony_service);
  18. /*   
  19. * Phone Status:
  20. * 1.tm. Call_state_idle=0 No Activity
  21. * 2.tm. Call_state_ringing=1 Bells
  22. * 3.tm. Call_state_offhook=2 Pick-up machine
  23. */
  24. Tm.getcallstate (); //int
  25. /*   
  26. * Phone Directions:
  27. *
  28. */
  29. Tm.getcelllocation (); //celllocation
  30. /*   
  31. * Unique Device ID:
  32. * GSM phone's IMEI and CDMA phone MEID.
  33. * Return NULL if device ID is not available.
  34. */
  35. Tm.getdeviceid (); //string
  36. /*   
  37. * Software version number of the device:
  38. * For example: The IMEI/SV (software version) for GSM phones.
  39. * Return NULL if the software version is not available.
  40. */
  41. Tm.getdevicesoftwareversion (); //string
  42. /*   
  43. * Phone Number:
  44. * GSM mobile phone's MSISDN.
  45. * Return NULL if it is unavailable.
  46. */
  47. Tm.getline1number (); //string
  48. /*   
  49. * Nearby Telephone information:
  50. * Type:list<neighboringcellinfo>
  51. * Requires permission: Android. Manifest.permission#access_coarse_updates
  52. */
  53. Tm.getneighboringcellinfo (); //list<neighboringcellinfo>
  54. /*   
  55. * Get the ISO Standard country code, which is the international long distance code.
  56. * Note: Only if the user has been registered with the network.
  57. * Results may not be reliable in CDMA networks.
  58. */
  59. Tm.getnetworkcountryiso (); //string
  60. /*   
  61. * MCC+MNC (Mobile Country code + mobile network Code)
  62. * Note: Only if the user is already active on the network registration.
  63. * Results may not be reliable in CDMA networks.
  64. */
  65. Tm.getnetworkoperator (); //string
  66. /*   
  67. * Name of current registered operator (currently registered user) in alphabetical order
  68. * Note: Only if the user is already active on the network registration.
  69. * Results may not be reliable in CDMA networks.
  70. */
  71. Tm.getnetworkoperatorname (); //string
  72. /*   
  73. * The type of network currently in use:
  74. * Example: Network_type_unknown network type unknown 0
  75. Network_type_gprs GPRS Network 1
  76. Network_type_edge EDGE Network 2
  77. NETWORK_TYPE_UMTS UMTS Network 3
  78. NETWORK_TYPE_HSDPA HSDPA Network 8
  79. Network_type_hsupa HSUPA Network 9
  80. Network_type_hspa HSPA Network 10
  81. NETWORK_TYPE_CDMA CDMA Network, is95a or is95b. 4
  82. NETWORK_TYPE_EVDO_0 EVDO Network, Revision 0. 5
  83. Network_type_evdo_a EVDO Network, revision A. 6
  84. Network_type_1xrtt 1xRTT Network 7
  85. */
  86. Tm.getnetworktype (); //int
  87. /*   
  88. * Phone Type:
  89. * For example: Phone_type_none no signal
  90. PHONE_TYPE_GSM GSM Signal
  91. PHONE_TYPE_CDMA CDMA Signal
  92. */
  93. Tm.getphonetype (); //int
  94. /*   
  95. * Returns the ISO Country code equivalent for the SIM provider ' s country code.
  96. * Obtain the ISO country code, which is equivalent to providing a SIM card country code.
  97. *
  98. */
  99. Tm.getsimcountryiso (); //string
  100. /*   
  101. * Returns the MCC+MNC (mobile Country code + mobile Network Code) of the provider of the SIM. 5 or 6 decimal digits.
  102. * Get the Mobile country Code and mobile network code provided by the SIM card. 5 or 6-bit decimal digits.
  103. * The status of the SIM card must be Sim_state_ready (use Getsimstate () to determine).
  104. */
  105. Tm.getsimoperator (); //string
  106. /*   
  107. * Name of service provider:
  108. * For example: China Mobile, Unicom
  109. * The status of the SIM card must be Sim_state_ready (use Getsimstate () to determine).
  110. */
  111. Tm.getsimoperatorname (); //string
  112. /*   
  113. * Serial number of SIM card:
  114. * Requires permission: read_phone_state
  115. */
  116. Tm.getsimserialnumber (); //string
  117. /*   
  118. * Status information of SIM:
  119. * Sim_state_unknown Unknown State 0
  120. Sim_state_absent Card 1
  121. sim_state_pin_required lock status, requires user PIN code to unlock 2
  122. sim_state_puk_required lock status, requires the user's PUK code unlock 3
  123. sim_state_network_locked lock status, requires network PIN code unlock 4
  124. Sim_state_ready Ready State 5
  125. */
  126. Tm.getsimstate (); //int
  127. /*   
  128. * Unique User id:
  129. * For example: IMSI (International Mobile User ID) for a GSM phone.
  130. * Requires permission: read_phone_state
  131. */
  132. Tm.getsubscriberid (); //string
  133. /*   
  134. * Gets the label associated with the voice mail, which is the identifier
  135. * Requires permission: read_phone_state
  136. */
  137. Tm.getvoicemailalphatag (); //string
  138. /*   
  139. * Get voice mail number:
  140. * Requires permission: read_phone_state
  141. */
  142. Tm.getvoicemailnumber (); //string
  143. /*   
  144. * The ICC card is present
  145. */
  146. Tm.hasicccard (); //boolean
  147. /*   
  148. * Whether to roam:
  149. * (under GSM use)
  150. */
  151. Tm.isnetworkroaming (); //     
  152. }
  153. }
  154. Turn http://blog.csdn.net/gumanren/archive/2011/02/26/6209237.aspx

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.