Deepak Tripathi
Deepak Tripathi

Reputation: 630

How to get IMEI in android 10

For security purposes, I want to store the IMEI number of app users but I am getting the following error

2020-02-14 13:29:36.620 14794-14794/com.udaan.android.creditoperations E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.udaan.android.creditoperations, PID: 14794
    java.lang.SecurityException: getImeiForSlot: The user 10643 does not meet the requirements to access device identifiers.
        at android.os.Parcel.createException(Parcel.java:2071)
        at android.os.Parcel.readException(Parcel.java:2039)
        at android.os.Parcel.readException(Parcel.java:1987)
        at com.android.internal.telephony.ITelephony$Stub$Proxy.getImeiForSlot(ITelephony.java:10471)
        at android.telephony.TelephonyManager.getImei(TelephonyManager.java:1754)
        at android.telephony.TelephonyManager.getImei(TelephonyManager.java:1715)

Is there any way to access IMEI number including latest android devices?

Upvotes: 3

Views: 15829

Answers (3)

Berker Sazan
Berker Sazan

Reputation: 51

From Android 10, there is no way to get it. Find an alternative unique identifier from document which shared by Abhishek.

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.

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

More details;

https://developer.android.com/about/versions/10/privacy/changes

Upvotes: 2

Abhishek
Abhishek

Reputation: 3584

Starting from Android 10, Third-party apps installed from the Google Play Store cannot get IMEI number. That's why you are getting this Security Exception.

I would suggest you use any other unique id for your purpose. For best practices of unique identifiers recommended by Google, you can check out the below link

https://developer.android.com/training/articles/user-data-ids

Upvotes: 3

Amrah Aziz
Amrah Aziz

Reputation: 81

Have you tried to add permission to AndroidManifest file?

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Upvotes: 0

Related Questions