温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android中如何获取手机信息

发布时间:2022-04-16 15:51:33 来源:亿速云 阅读:213 作者:iii 栏目:开发技术

这篇文章主要介绍“Android中如何获取手机信息”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Android中如何获取手机信息”文章能帮助大家解决问题。

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

java代码:

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

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

java代码:

private void loadPhoneStatus(){     TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);     txtPhoneModel.setText(Build.MODEL); //手机型号     txtPhoneNumber.setText(phoneMgr.getLine1Number());//本机电话号码     txtSdkVersion.setText(Build.VERSION.SDK);//SDK版本号     txtOsVersion.setText(Build.VERSION.RELEASE);//Firmware/OS 版本号  }

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

Java代码:

String  BOARD  The name of the underlying board, like "goldfish".   String  BOOTLOADER  The system bootloader version number.   String  BRAND  The brand (e.g., carrier) the software is customized for, if any.   String  CPU_ABI  The name of the instruction set (CPU type + ABI convention) of native code.   String  CPU_ABI2  The name of the second instruction set (CPU type + ABI convention) of native code.   String  DEVICE  The name of the industrial design.   String  DISPLAY  A build ID string meant for displaying to the user   String  FINGERPRINT  A string that uniquely identifies this build.   String  HARDWARE  The name of the hardware (from the kernel command line or /proc).   String  HOST   String  ID  Either a changelist number, or a label like "M4-rc20".   String  MANUFACTURER  The manufacturer of the product/hardware.   String  MODEL  The end-user-visible name for the end product.   String  PRODUCT  The name of the overall product.   String  RADIO  The radio firmware version number.   String  SERIAL  A hardware serial number, if available.   String  TAGS  Comma-separated tags describing the build, like "unsigned,debug".  long  TIME   String  TYPE  The type of build, like "user" or "eng".   String  UNKNOWN  Value used for when a build property is unknown.   String  USER

效果图:

Android中如何获取手机信息

关于“Android中如何获取手机信息”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注亿速云行业资讯频道,小编每天都会为大家更新不同的知识点。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI