您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關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中怎么獲取手機信息了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。