Android入门学习_Android获取手机信息

       Android开发平台中,可通过TelephonyManager 获取本机号码。

java代码:
  1. TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);

  2. txtPhoneNumber.setText(phoneMgr.getLine1Number()); //txtPhoneNumber是一个EditText 用于显示手机号
复制代码

       注:根据Android的安全机制,在使用TelephonyManager时,必须在AndroidManifest.xml中添加<uses-permission android:name="READ_PHONE_STATE" /> 否则无法获得系统的许可。
手机型号 Build.MODEL

java代码:
  1. private void loadPhoneStatus(){

  2. TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);

  3. txtPhoneModel.setText(Build.MODEL); //手机型号
  4. txtPhoneNumber.setText(phoneMgr.getLine1Number());//本机电话号码
  5. txtSdkVersion.setText(Build.VERSION.SDK);//SDK版本号
  6. txtOsVersion.setText(Build.VERSION.RELEASE);//Firmware/OS 版本号
  7. }
复制代码

       事实上,Build能向我们提供包括 硬件厂商,硬件编号,序列号等很多信息 调用方法也都同上,很简单。

java代码:
  1. String
  2. BOARD
  3. The name of the underlying board, like "goldfish".

  4. String
  5. BOOTLOADER
  6. The system bootloader version number.

  7. String
  8. BRAND
  9. The brand (e.g., carrier) the software is customized for, if any.

  10. String
  11. CPU_ABI
  12. The name of the instruction set (CPU type + ABI convention) of native code.

  13. String
  14. CPU_ABI2
  15. The name of the second instruction set (CPU type + ABI convention) of native code.

  16. String
  17. DEVICE
  18. The name of the industrial design.

  19. String
  20. DISPLAY
  21. A build ID string meant for displaying to the user

  22. String
  23. FINGERPRINT
  24. A string that uniquely identifies this build.

  25. String
  26. HARDWARE
  27. The name of the hardware (from the kernel command line or /proc).

  28. String
  29. HOST

  30. String
  31. ID
  32. Either a changelist number, or a label like "M4-rc20".

  33. String
  34. MANUFACTURER
  35. The manufacturer of the product/hardware.

  36. String
  37. MODEL
  38. The end-user-visible name for the end product.

  39. String
  40. PRODUCT
  41. The name of the overall product.

  42. String
  43. RADIO
  44. The radio firmware version number.

  45. String
  46. SERIAL
  47. A hardware serial number, if available.

  48. String
  49. TAGS
  50. Comma-separated tags describing the build, like "unsigned,debug".

  51. long
  52. TIME

  53. String
  54. TYPE
  55. The type of build, like "user" or "eng".

  56. String
  57. UNKNOWN
  58. Value used for when a build property is unknown.

  59. String
  60. USER
复制代码

效果图:

2.png

前天 14:19 上传
下载附件 (24.92 KB)



你可能感兴趣的:(Android入门学习_Android获取手机信息)