/获取手机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;
}
原文:https://blog.youkuaiyun.com/ReCclay/article/details/81676991
Android获取IMEI码
最新推荐文章于 2025-05-16 11:22:04 发布