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?
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
您是否尝试过为 AndroidManifest 文件添加权限?
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.