Recently, there is a requirement in the project that needs to obtain the information of the Android device, such as Huawei, Android10.
It can be parsed out by request.getHeader("User-Agent");. However, practice has proved that Huawei mobile phones cannot get information such as the mobile phone model.
Through many times of Baidu Baidu, I found that Google's Android package has this magical effect.
First, maven imports
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
</dependency>
Some basic information can be obtained in android.os.Build in the class, as follows
Build.BOARD:获取设备基板名称
Build.BOOTLOADER:获取设备引导程序版本号
Build.BRAND:获取设备品牌
Build.CPU_ABI:获取设备指令集名称(CPU的类型)
Build.CPU_ABI2:获取第二个指令集名称
Build.DEVICE:获取设备驱动名称
Build.DISPLAY:获取设备显示的版本包(在系统设置中显示为版本号)和ID一样
Build.FINGERPRINT:设备的唯一标识。由设备的多个信息拼接合成
Build.HARDWARE:设备硬件名称,一般和基板名称一样(BOARD)
Build.HOST:设备主机地址
Build.ID:设备版本号
Build.MODEL:获取手机的型号 设备名称。如:SM-N9100(三星Note4)
Build.MANUFACTURER:获取设备制造商。如:samsung
Build.PRODUCT:产品的名称
Build.RADIO:无线电固件版本号,通常是不可用的 显示
public class MainActivity extends android.app.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);
}