Search code examples
androidmdmdevice-owner

getIMEI() is returning null in Android (device owner)


My app is a device owner but still getIMEI() is returning null in Android 9 and I have provided <READ_PHONE_STATE> permission also.

As per the Android Developers Documentation : (https://developer.android.com/about/versions/10/privacy/changes#non-resettable-device-ids)

Note: If your app is the device or profile owner app, you need only the READ_PHONE_STATE permission to access non-resettable device identifiers, even if your app targets Android 10 or higher. Also, if your app has special carrier permissions, you don't need any permissions to access the identifiers.


Solution

  • If your targetSdkVersion is 29 (Android 10) or later, then you will get a null value when requesting IMEI (or one of several other identifiers) if you're running Android 9 or earlier. See the doc about Privacy Changes in Android 10 for more info.