出于安全考虑,我想存储应用程序用户的 IMEI 号码,但出现以下错误
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)
有没有办法访问 IMEI 号码,包括最新的安卓设备?
最佳答案
从 Android 10 开始,从 Google Play 商店安装的第三方应用程序无法获取 IMEI 号码。
这就是您收到此安全异常的原因。
我建议您为您的目的使用任何其他唯一 ID。有关 Google 推荐的唯一标识符的最佳做法,您可以查看以下链接
https://developer.android.com/training/articles/user-data-ids
关于android - 如何在Android 10中获取IMEI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60222400/