Trying to apply the @RequiresPermission
annotation as explained in tech-docs.
The example shows
If you require at least one from a set of permissions, you can use the anyOf attribute:
@RequiresPermission(anyOf = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}) public abstract Location getLastKnownLocation(String provider);
I try to apply it in my code, which does some bluetooth scanning:
@RequiresPermission(anyOf = {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION})
private void initiateConnectionProcess() {
startScanAndBroadcast();
}
which gives an error
Only specify one of value, anyOf or allOf
I thought maybe startScanAndBroadcast()
has a allOf
annotation that could cause problems if the annotations are resolved recursively, but that method has no annotations at all.
The error remains if the method body is blank.
The error goes away if I don't list the permissions:
@RequiresPermission(anyOf = { })
private void initiateConnectionProcess() {
What's going wrong here?