Android 获取手机信息

 

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

  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

  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能向我们提供包括 硬件厂商,硬件编号,序列号等很多信息 调用方法也都同上,下面是Build中的API中定义。

public          static          final           String BOARDThe name of the underlying board, like "goldfish".
          public          static          final           String BOOTLOADERThe system bootloader version number.
          public          static          final           String BRANDThe brand (e.g., carrier) the software is customized for, if any.
          public          static          final           String CPU_ABIThe name of the instruction set (CPU type + ABI convention) of native code.
          public          static          final           String CPU_ABI2The name of the second instruction set (CPU type + ABI convention) of native code.
          public          static          final           String DEVICEThe name of the industrial design.
          public          static          final           String DISPLAYA build ID string meant for displaying to the user
          public          static          final           String FINGERPRINTA string that uniquely identifies this build.
          public          static          final           String HARDWAREThe name of the hardware (from the kernel command line or /proc).
          public          static          final           String HOST 
          public          static          final           String IDEither a changelist number, or a label like "M4-rc20".
          public          static          final           String MANUFACTURERThe manufacturer of the product/hardware.
          public          static          final           String MODELThe end-user-visible name for the end product.
          public          static          final           String PRODUCTThe name of the overall product.
          public          static          final           String RADIOThe radio firmware version number.
          public          static          final           String SERIALA hardware serial number, if available.
          public          static          final           String TAGSComma-separated tags describing the build, like "unsigned,debug".
          public          static          final          long TIME 
          public          static          final           String TYPEThe type of build, like "user" or "eng".
          public          static          final           String USER 


效果图:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值