基于JAVA代码 获取手机基本信息(本机号码,SDK版本,系统版本,手机型号)

老风格,废话不多说了,直接给大家贴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);

声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:notice#cainiaojc.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。