Android gets the IMEI number

Source: Internet
Author: User

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

  1. /** 
  2. *
  3. * Creation date: 05:02:47 
  4. */
  5. PackageNet. sunniwell. app;
  6. ImportAndroid. App. activity;
  7. ImportAndroid. OS. Bundle;
  8. ImportAndroid. telephony. celllocation;
  9. ImportAndroid. telephony. phonestatelistener;
  10. ImportAndroid. telephony. telephonymanager;
  11. Public ClassTelmanagerExtendsActivity {
  12. @ Override
  13. Protected VoidOncreate (bundle savedinstancestate ){
  14. Super. Oncreate (savedinstancestate );
  15. Telephonymanager TM = (telephonymanager)This. Getsystemservice (telephony_service );
  16. /* 
  17. * Phone status: 
  18. * 1. tm. call_state_idle = 0 no activity 
  19. * 2. tm. call_state_ringing = 1 bell 
  20. * 3. tm. call_state_offhook = 2 disconnect 
  21. */
  22. TM. getcallstate ();// Int
  23. /* 
  24. * Phone location: 
  25. */
  26. TM. getcelllocation ();// Celllocation
  27. /* 
  28. * Unique device ID: 
  29. * The IMEI of the GSM mobile phone and the meid of the CDMA mobile phone. 
  30. * Return NULL if device ID is not available. 
  31. */
  32. TM. getdeviceid ();// String
  33. /* 
  34. * Software version number of the device: 
  35. * For example, the IMEI/SV (Software Version) for GSM phones. 
  36. * Return NULL if the software version is not available. 
  37. */
  38. TM. getdevicesoftwareversion ();// String
  39. /* 
  40. * Mobile phone number: 
  41. * Msisdn of the GSM mobile phone. 
  42. * Return NULL if it is unavailable. 
  43. */
  44. TM. getline1number ();// String
  45. /* 
  46. * Nearby phone information: 
  47. * Type: List <neighboringcellinfo> 
  48. * Permission required: Android. manifest. Permission # access_coarse_updates 
  49. */
  50. TM. getneighboringcellinfo ();// List <neighboringcellinfo>
  51. /* 
  52. * Obtain the ISO Standard Country Code, that is, the international long-distance area code. 
  53. * Note: it is valid only after the user has registered the network. 
  54. * The results may be unreliable in CDMA networks. 
  55. */
  56. TM. getnetworkcountryiso ();// String
  57. /* 
  58. * MCC + MNC (mobile country code + mobile network code) 
  59. * Note: it is valid only when the user has registered the network. 
  60. * The results may be unreliable in CDMA networks. 
  61. */
  62. TM. getnetworkoperator ();// String
  63. /* 
  64. * The Name Of The current registered operator (currently registered user) in alphabetical order 
  65. * Note: it is valid only when the user has registered the network. 
  66. * The results may be unreliable in CDMA networks. 
  67. */
  68. TM. getnetworkoperatorname ();// String
  69. /* 
  70. * Current network type: 
  71. * For example, The network_type_unknown network type is unknown. 0 
  72. Network_type_gprs GPRS network 1 
  73. Network_type_edge Network 2 
  74. Network_type_umts UMTS network 3 
  75. Network_type_hsdpa HSDPA network 8 
  76. Network_type_hsupa hsupa network 9 
  77. Network_type_hspa HSPA network 10 
  78. Network_type_cdma network, is95a or is95b. 4 
  79. Network_type_evdo_0 evdo network, Revision 0. 5 
  80. Network_type_evdo_a evdo network, Revision A. 6 
  81. Network_type_1xrtt 1xrtt network 7 
  82. */
  83. TM. getnetworktype ();// Int
  84. /* 
  85. * Mobile Phone type: 
  86. * For example, phone_type_none has no signal. 
  87. Phone_type_gsm GSM Signal 
  88. Phone_type_cdma Signal 
  89. */
  90. TM. getphonetype ();// Int
  91. /* 
  92. * Returns the ISO country code equivalent for the sim provider's country code. 
  93. * Obtain the ISO country code, which is equivalent to the Country Code that provides the SIM card. 
  94. */
  95. TM. getsimcountryiso ();// String
  96. /* 
  97. * Returns the MCC + MNC (mobile country code + mobile network code) of the provider of the sim. 5 or 6 decimal digits. 
  98. * Obtain the mobile country code and mobile network code. 5 or 6-digit decimal number provided by the SIM card. 
  99. * The SIM card status must be sim_state_ready (determined by getsimstate ). 
  100. */
  101. TM. getsimoperator ();// String
  102. /* 
  103. * Service provider name: 
  104. * For example, China Mobile and China Unicom 
  105. * The SIM card status must be sim_state_ready (determined by getsimstate ). 
  106. */
  107. TM. getsimoperatorname ();// String
  108. /* 
  109. * Sim card serial number: 
  110. * Permission required: read_phone_state 
  111. */
  112. TM. getsimserialnumber ();// String
  113. /* 
  114. * Sim status information: 
  115. * Sim_state_unknown unknown status 0 
  116. Sim_state_absent no card 1 
  117. Sim_state_pin_required lock status, which requires the user's pin code to be unlocked 2 
  118. Sim_state_puk_required lock status, which requires the user's pukcode to be unlocked 3 
  119. Sim_state_network_locked lock status, which requires the network pin to be unlocked 4 
  120. Sim_state_ready ready status 5 
  121. */
  122. TM. getsimstate ();// Int
  123. /* 
  124. * Unique User ID: 
  125. * For example, imsi (International Mobile User Identification Code) for a gsm phone. 
  126. * Permission required: read_phone_state 
  127. */
  128. TM. getsubscriberid ();// String
  129. /* 
  130. * Obtain the tags related to the voice mail, that is, the identifier. 
  131. * Permission required: read_phone_state 
  132. */
  133. TM. getvoicemailalphatag ();// String
  134. /* 
  135. * Obtain the voice mail Number: 
  136. * Permission required: read_phone_state 
  137. */
  138. TM. getvoicemailnumber ();// String
  139. /* 
  140. * Whether the ICC card exists 
  141. */
  142. TM. hasicccard ();// Boolean
  143. /* 
  144. * Roaming or not: 
  145. * (For GSM purposes) 
  146. */
  147. TM. isnetworkroaming ();//
  148. }
  149. }
  150. TransferHttp://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.