从Android 10开始,应用必须具有READ_PRIVILEGED_PHONE_STATE
特权,才能访问设备的不可重置标识符,包括IMEI和序列号.
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.
从Google Play商店安装的第三方应用无法声明特权.
Third-party apps installed from the Google Play Store cannot declare privileged permissions.
如果您的应用没有权限,并且无论如何您都尝试询问有关不可重置标识符的信息,则平台的响应会根据目标SDK版本而有所不同:
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:
- 如果您的应用定位到Android 10或更高版本,则会发生SecurityException.
- 如果您的应用程序针对Android 9(API级别28)或更低版本,则如果该应用程序具有
READ_PHONE_STATE
权限,则该方法将返回null或占位符数据.否则,将发生SecurityException.
- 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.
如果您尝试访问它,它将引发以下异常:
java.lang.SecurityException: getImeiForSlot: The user 10180 does not meet the requirements to access device identifiers.
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.
这篇关于如何获取有关Android 10中手机的IMEI的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!