//获取手机设备号
TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
return;
}
//8.0及以后版本获取
if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
PermissionUtils.IMEI = TelephonyMgr.getDeviceId();
}else{//9.0到10.0获取
PermissionUtils.IMEI = Settings.System.getString(
getContentResolver(), Settings.Secure.ANDROID_ID);
}
Log.e("IMEI:", "IMEI: " + PermissionUtils.IMEI);
网友评论