android getdeviceid 权限,imei - Access getDeviceID() for a Device Owner App Android 10? - Stack Overfl...

在Android 10及以上版本,通过getDeviceId()获取IMEI受到更严格的权限限制。尽管尝试将应用设为设备所有者,但仍然遇到SecurityException。问题可能在于用户权限不足。要解决IMEI访问问题,需要确保应用拥有适当的权限声明并在合适的安全上下文中运行。
摘要由CSDN通过智能技术生成

I have many phones I need to register in a database with IMEI barcodes and install a company app on it to connect and track them. For this purpose I need to access the IMEI with getDeviceID(). Since Android 10, it is not as simple.

In this page, Android says if you are device owner you can access it : https://developer.android.com/training/articles/user-data-ids

I use this method to make my app a device owner app :

How to make my app a device owner?

adb shell dpm set-device-owner com.package.name/.MyDeviceAdminReceiver

When I use getDeviceId() in the app, I still have the error :

java.lang.SecurityException: getDeviceId: The user 10180 does not meet the requirements to access device identifiers.

Why this method doesn't work ?

Do you have any suggestions to the IMEI ?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值