Android编程获取手机型号,本机电话号码,sdk版本及firmware版本号(即系统版本号)...
Android開發(fā)平臺(tái)中,可通過TelephonyManager 獲取本機(jī)號(hào)碼。
?
TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);txtPhoneNumber.setText(phoneMgr.getLine1Number()); //txtPhoneNumber是一個(gè)EditText 用于顯示手機(jī)號(hào)
注:
根據(jù)Android的安全機(jī)制,在使用TelephonyManager時(shí),必須在AndroidManifest.xml中添加<uses-permission android:name="READ_PHONE_STATE" /> 否則無法獲得系統(tǒng)的許可。
?
手機(jī)型號(hào) Build.MODEL
| String | MODEL | The end-user-visible name for the end product. |
sdk版本 Build.VERSION.SDK
| String | SDK | This constant is deprecated. Use?SDK_INT?to easily get this as an integer. |
及frimware版本號(hào)(系統(tǒng)版本號(hào)) Build.VERSION.RELEASE
| String | RELEASE | The user-visible version string. |
?
private void loadPhoneStatus(){
TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
txtPhoneModel.setText(Build.MODEL); //手機(jī)型號(hào)
txtPhoneNumber.setText(phoneMgr.getLine1Number());//本機(jī)電話號(hào)碼
txtSdkVersion.setText(Build.VERSION.SDK);//SDK版本號(hào)
txtOsVersion.setText(Build.VERSION.RELEASE);//Firmware/OS 版本號(hào)
}
事實(shí)上,Build能向我們提供包括 硬件廠商,硬件編號(hào),序列號(hào)等很多信息 調(diào)用方法也都同上,很簡(jiǎn)單。
| 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平臺(tái)軟件開發(fā),我的手機(jī)號(hào)是韓國的啦。所以看到010打頭的號(hào)碼,別太驚訝..
我的聯(lián)系方式:
http://www.mobiletuts.me
或
mobiletuts.me#gmail.com (replace #with @)
手頭做的項(xiàng)目涉及到Android平臺(tái)中網(wǎng)絡(luò)設(shè)置,數(shù)據(jù)庫,http協(xié)議下的數(shù)據(jù)傳輸,支付系統(tǒng),以及SNS API(twitter, facebook, me2day, etc), QR碼掃描等模塊。
如果大家感興趣的話,我會(huì)在開發(fā)閑暇時(shí)間陸續(xù)將常用的一些模塊的開發(fā)調(diào)用,寫成獨(dú)立,簡(jiǎn)潔的教程發(fā)上來。
轉(zhuǎn)載于:https://www.cnblogs.com/mainroadlee/archive/2011/01/09/Get_Phone_Number_Model_SDKVersion_Information_in_Android_SDK.html
總結(jié)
以上是生活随笔為你收集整理的Android编程获取手机型号,本机电话号码,sdk版本及firmware版本号(即系统版本号)...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: cad编辑节点快捷键是什么_cad201
- 下一篇: 旧题新做:从idy的视角看数据结构