SecurityException: getSerial: The user 10134 does not meet the requirements to access device identifiers

﹥>﹥吖頭↗ 提交于 2020-05-16 03:53:12

问题


I want to get the Build.getSerial() from the Android phone. Up to Android O i needed the Manifest.permission.READ_PHONE_STATE permission. However in Android 10 i get the above exception. What i did is added this permission to the manifest

<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
        tools:ignore="ProtectedPermissions"/>

And in the activity i need to request for the permission but there is not such a permission

ActivityCompat.requestPermissions(this@ListActivity, 
   arrayOf(Manifest.permission.READ_PHONE_STATE, 
   <<Manifest.permission.READ_PRIVILEGED_PHONE_STATE>>), 
   SERIAL_NUMBER_PERMISSION)

So how can i get the serial Number if i cannot Grant the permission..? What should i do?


回答1:


Refer the documentation here:

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

As such only google apps and phone manufacturer apps (or if you are device admin or owner app) can access previleged permissions



来源:https://stackoverflow.com/questions/59863895/securityexception-getserial-the-user-10134-does-not-meet-the-requirements-to-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!