老风格,废话不多说了,直接给大家贴java代码了。
代码如下:
package com.zzw.getPhoneInfos; import android.app.Activity; import android.content.Context; import android.os.Build; import android.os.Bundle; import android.telephony.TelephonyManager; import android.util.Log; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 获取电话管理对象 TelephonyManager mTelephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); // 获取手机号码 String phoneNumber = mTelephonyManager.getLine1Number(); Log.d("获取本机电话号码--->", phoneNumber); // 获取手机型号 String phoneModel = Build.MODEL; Log.d("获取手机型号--->", phoneModel); // 获取SDK版本 String phoneSdkVersion = Build.VERSION.SDK; Log.d("获取SDK版本--->", phoneSdkVersion); // 获取系统版本 String phoneReleaseVersion = Build.VERSION.RELEASE; Log.d("获取手机系统版本-->", phoneReleaseVersion); } }
不要忘记权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
结果如图:
java android 获取手机操作系统相关信息
String phoneInfo = "Product: " + android.os.Build.PRODUCT; phoneInfo += ", CPU_ABI: " + android.os.Build.CPU_ABI; phoneInfo += ", TAGS: " + android.os.Build.TAGS; phoneInfo += ", VERSION_CODES.BASE: " + android.os.Build.VERSION_CODES.BASE; phoneInfo += ", MODEL: " + android.os.Build.MODEL; phoneInfo += ", SDK: " + android.os.Build.VERSION.SDK; phoneInfo += ", VERSION.RELEASE: " + android.os.Build.VERSION.RELEASE; phoneInfo += ", DEVICE: " + android.os.Build.DEVICE; phoneInfo += ", DISPLAY: " + android.os.Build.DISPLAY; phoneInfo += ", BRAND: " + android.os.Build.BRAND; phoneInfo += ", BOARD: " + android.os.Build.BOARD; phoneInfo += ", FINGERPRINT: " + android.os.Build.FINGERPRINT; phoneInfo += ", ID: " + android.os.Build.ID; phoneInfo += ", MANUFACTURER: " + android.os.Build.MANUFACTURER; phoneInfo += ", USER: " + android.os.Build.USER; // Toast.makeText(this, phoneInfo, Toast.LENGTH_LONG).show(); TextView t = (TextView) findViewById(R.id.main_phoneinfo); t.setText(phoneInfo);
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索java获取手机信息
java手机信息
手游sdk系统源码、支付宝sdk 系统繁忙、视频会议系统sdk、系统源码和sdk源码、sdk系统,以便于您获取更多的相关知识。
时间: 2024-10-25 10:03:34