How do I get information about a phone's IMEI in Android 10?

Ajay Chauhan picture Ajay Chauhan · Oct 1, 2019 · Viewed 7k times · Source

Before Android 10, I was using the TelephonyManager API to retrieve that info, but it's no longer working in Android 10.

Answer

Kaushik Burkule picture Kaushik Burkule · Oct 1, 2019

From the Android Developers Documentation Website

Starting in Android 10, apps must have the READ_PRIVILEGED_PHONE_STATE privileged permission in order to access the device's non-resettable identifiers, which include both IMEI and serial number.

Third-party apps installed from the Google Play Store cannot declare privileged permissions.

If your app doesn't have the permission and you try asking for information about non-resettable identifiers anyway, the platform's response varies based on target SDK version:

  • If your app targets Android 10 or higher, a SecurityException occurs.
  • 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.

If you try to access it, it throws the below exception: java.lang.SecurityException: getImeiForSlot: The user 10180 does not meet the requirements to access device identifiers.