I came to know the privacy changes for Android 10 and I'm quite clear that third-party apps won't be able to get IMEI now. But one thing from documentation is creating confusion for me.
They state
If your app targets Android 9 (API level 28) or lower, the method returns null or placeholder data if the app has the READ_PHONE_STATE permission. Otherwise, a SecurityException occurs.
which means that on Android devices with API LEVEL 28 or lower, this method returns null
or placeholder
data, even if the app is having READ_PHONE_STATE
permission. Right?
But I have tested this thing on my app targetting API LEVEL 28
and I am still able to get IMEI number
with the following.
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
fragment.requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_CODE);
}
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = telephonyManager.getImei();
Shouldn't it send me NULL
or placeholder (garbage) data?
any idea about it? or am I misinterpreting it?