这期内容当中小编将会给大家带来有关Android中怎么获取手机信息,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
创新互联专业为企业提供崇川网站建设、崇川做网站、崇川网站设计、崇川网站制作等企业网站建设、网页设计与制作、崇川企业网站模板建站服务,10年崇川做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
Android开发平台中,可通过TelephonyManager 获取本机号码。
java代码:
TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE); txtPhoneNumber.setText(phoneMgr.getLine1Number()); //txtPhoneNumber是一个EditText 用于显示手机号
注:根据Android的安全机制,在使用TelephonyManager时,必须在AndroidManifest.xml中添加
手机型号 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中怎么获取手机信息了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。