I have an application that needs to download data, for that the IMEI of the device has been previously registered in the base, the problem has worked well, now that I use a device with API 27 the IMEI returns it to me null.
public String getIMEINumber() {
String IMEINumber = "";
if (ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.READ_PHONE_STATE) ==
PackageManager.PERMISSION_GRANTED) {
TelephonyManager telephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
IMEINumber = telephonyMgr.getImei();
} else {
IMEINumber = telephonyMgr.getDeviceId();
}
}
return IMEINumber;
}
I have read and I see that the documentation says that it returns null if the IMEI is not available, I wonder in what cases it is not available? (if I have added the permissions in the MANIFEST)