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 版本号  

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

Java代码:

  1. String  
  2. BOARD  
  3. The name of the underlying board, like "goldfish".  
  4.  
  5. String  
  6. BOOTLOADER  
  7. The system bootloader version number.  
  8.  
  9. String  
  10. BRAND  
  11. The brand (e.g., carrier) the software is customized for, if any.  
  12.  
  13. String  
  14. CPU_ABI  
  15. The name of the instruction set (CPU type + ABI convention) of native code.  
  16.  
  17. String  
  18. CPU_ABI2  
  19. The name of the second instruction set (CPU type + ABI convention) of native code.  
  20.  
  21. String  
  22. DEVICE  
  23. The name of the industrial design.  
  24.  
  25. String  
  26. DISPLAY  
  27. A build ID string meant for displaying to the user  
  28.  
  29. String  
  30. FINGERPRINT  
  31. A string that uniquely identifies this build.  
  32.  
  33. String  
  34. HARDWARE  
  35. The name of the hardware (from the kernel command line or /proc).  
  36.  
  37. String  
  38. HOST  
  39.  
  40. String  
  41. ID  
  42. Either a changelist number, or a label like "M4-rc20".  
  43.  
  44. String  
  45. MANUFACTURER  
  46. The manufacturer of the product/hardware.  
  47.  
  48. String  
  49. MODEL  
  50. The end-user-visible name for the end product.  
  51.  
  52. String  
  53. PRODUCT  
  54. The name of the overall product.  
  55.  
  56. String  
  57. RADIO  
  58. The radio firmware version number.  
  59.  
  60. String  
  61. SERIAL  
  62. A hardware serial number, if available.  
  63.  
  64. String  
  65. TAGS  
  66. Comma-separated tags describing the build, like "unsigned,debug".  
  67. long  
  68. TIME  
  69.  
  70. String  
  71. TYPE  
  72. The type of build, like "user" or "eng".  
  73.  
  74. String  
  75. UNKNOWN  
  76. Value used for when a build property is unknown.  
  77.  
  78. String  
  79. USER 

效果图:

【编辑推荐】

Android UI设计模式

Android开发之旅:Android架构

Android Phone 7界面设置小教程

Android系统手机隐藏代码大全曝光

Android Activity和Intent机制学习笔记

责任编辑:zhaolei 来源: 互联网
相关推荐

2010-08-12 13:11:54

Universal AAndroid开发

2013-07-02 09:29:52

2011-06-18 10:55:30

中电信摩托罗拉华为

2015-05-25 11:04:18

2024-04-11 08:26:34

Android系统命令

2013-03-29 10:47:39

Android获取经纬AndroidGPS定

2023-01-31 10:21:00

RobustaKubernetes

2009-11-13 10:53:54

ADO.NET Dat

2021-04-13 10:57:02

LinuxCPUCLI

2021-04-21 09:44:18

LinuxCPUCLI工具

2013-03-29 10:24:44

NDK隐藏敏感信息Android

2011-08-12 14:00:36

iPhone硬件版本系统信息

2013-01-04 17:44:59

2011-02-16 11:49:06

2011-12-21 16:44:00

信息图手机进化史

2024-03-04 14:59:51

鸿蒙CPU信息C++

2016-12-12 09:39:40

2010-02-04 15:38:39

Android 手机

2017-11-13 14:40:45

android代码WIFI

2012-08-22 16:09:35

点赞
收藏

51CTO技术栈公众号