gpt4 book ai didi

android - 调用 requiresPermission 注释方法时缺少权限提示

转载 作者:行者123 更新时间:2023-11-29 00:56:35 24 4
gpt4 key购买 nike

我正在开发一个必须通过 .aar 文件包含在项目中的小 sdk。在这个 sdk 中,我有一个如下定义的方法:

/**
* Sends an "open lock" request for the bike, with the ble name provided as param. Requires ACCESS_FINE_LOCATION and
* BLUETOOTH permission
*
* @param bikeBleName The BLE name of the searched bike, normally starts with 'BS' prefix
* @param listener Listener for the operation state, returns success or an error string with the detailed error

*/
@RequiresPermission(allOf = [Manifest.permission.BLUETOOTH, Manifest.permission.ACCESS_FINE_LOCATION])
override fun startRent(bikeBleName: String, bikeMode: BikeMode, listener: StartRentListener) {
GlobalScope.launch {
startRentManager.startRent(bikeBleName, bikeMode, listener)
}
}

如您所见,该方法使用 @RequiresPermission(allOf = [Manifest.permission.BLUETOOTH, Manifest.permission.ACCESS_FINE_LOCATION]) 注释,但是,如果我从我的项目中调用该方法MainActivity,Android Studio 告诉我该方法需要进行权限检查,但没有告诉我需要哪些权限。我想要获得的是 Android Studio 告诉我“此方法需要 ACCESS_FINE_LOCATION 和 BLUETOOTH 权限”,类似于下面的屏幕截图。我怎样才能做到这一点?谢谢

enter image description here

库模块的 list 文件是:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.zehus.bikeaccesssdk">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
</manifest>

最佳答案

问题是我放了

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.zehus.bikeaccesssdk">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
</manifest>

在库模块中。我从库 list 中删除了权限,现在 Android Studio 提供了正确的提示。

关于android - 调用 requiresPermission 注释方法时缺少权限提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54304684/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com