Getting W/Activity: Can request only one set of permissions at a time
So, I can't see your requestPermission()
method from here, but you shouldn't send multiple permission requests in the same time.
You should make ONE request with ALL the permissions.
Kotlin:
val permissionsCode = 42
val permissions = arrayOf(Manifest.permission.CAMERA, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
if (!hasPermissions(this, permissions)) {
ActivityCompat.requestPermissions(this, permissions, permissionsCode)
}
Java:
int permissionsCode = 42;
String[] permissions = {Manifest.permission.CAMERA, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION};
if (!hasPermissions(this, permissions)) {
ActivityCompat.requestPermissions(this, permissions, permissionsCode);
}
For anyone else stumbling upon this issue..You need to request permissions serially,like this:
onRequestPermissionResult(){
case permission1:
if (permission1.aquired()){
....//do what you do
requestPermission2();
}
case permission2:
if (permission2.aquired()){
....//do what you do
requestPermission3();
}
}
I think problem is that you ask for two location permissions, you should ask only for fine location which will work for both coarse and fine.