/*获取手机IMEI号*/
private static String getDeviceId(Context context) {
String id = "test";
//android.telephony.TelephonyManager
TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
if (mTelephony.getDeviceId() != null)
{
id = mTelephony.getDeviceId();
} else {
//android.provider.Settings;
id = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
}
}
return id;
}
Android学习之获取手机的IMEI号
最新推荐文章于 2024-07-15 02:48:48 发布