Android Request Permission annotation conditional
Asked Answered
U

1

6

I am building an SDK API with beacons integration which requires Bluetooth scan permission for android 12 and above. So, I added annotation for the API like this:

@RequiresPermission(allOf = [Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.BLUETOOTH_SCAN])
fun enableBeaconScan()

When I add this, I am getting a warning:

enter image description here

Is there a way to restrict this permission only for the supported android versions and get rid of this warning?

Unrobe answered 9/6, 2022 at 4:2 Comment(1)
Di you find any solution?Jayjaycee
N
-1

you can use this annotation

@TargetApi(Build.VERSION_CODES.S)

Ninety answered 9/6, 2022 at 5:58 Comment(1)
If I use this, the entire API is marked as requires API S, I want the permission only to be annotated and asked for the Build.VERSION_CODES.S and aboveUnrobe

© 2022 - 2024 — McMap. All rights reserved.