-1

when I execute this code

        while (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED  && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
    }

I get this warning W/Activity: Can request only one set of permissions at a time W/Activity: Can request only one set of permissions at a time is there any way to fix this?

1 Answers1

-1

Two things here, firstly I don't think you need two set of Location Permissions, if you are using ACCESS_FINE_LOCATION then Coarse should be covered well under it.

Secondly, instead of sending separate request for permissions, you should make one combined set of requests and send it. That should work.

int permissions_code = 42; 
String[] permissions = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION};

 ActivityCompat.requestPermissions(this, permissions, permissions_code);
che10
  • 2,176
  • 2
  • 4
  • 11