Android中获取手机信息
创始人
2024-07-30 20:01:32
0

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

java代码:

  1. TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);  
  2. txtPhoneNumber.setText(phoneMgr.getLine1Number()); //txtPhoneNumber是一个EditText 用于显示手机号 

注:根据Android的安全机制,在使用TelephonyManager时,必须在AndroidManifest.xml中添加 否则无法获得系统的许可。
手机型号 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机制学习笔记

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
着眼MAC地址,解救无法享受D... 在安装了DHCP服务器的局域网环境中,每一台工作站在上网之前,都要先从DHCP服务器那里享受到地址动...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...