SecurityException:getSerial:用户10134不符合访问设备标识符的要求 [英] SecurityException: getSerial: The user 10134 does not meet the requirements to access device identifiers

查看:3584
本文介绍了SecurityException:getSerial:用户10134不符合访问设备标识符的要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Android手机获取Build.getSerial().最高Android O,我需要Manifest.permission.READ_PHONE_STATE权限.但是在Android 10中,我得到了上述异常. 我所做的就是将此权限添加到清单中

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?

推荐答案

请参阅

警告:从Google Play商店安装的第三方应用无法声明特权.

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

因此,只有google应用程序和电话制造商应用程序(或者如果您是设备管理员或所有者应用程序)可以访问特权权限

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

这篇关于SecurityException:getSerial:用户10134不符合访问设备标识符的要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆