时间:2020-10-30 16:30:34 | 栏目:JAVA代码 | 点击:次
老风格,废话不多说了,直接给大家贴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);