I'm here a bit late. But I have the exact response for you and for everyone that is looking for the same. The clue is to handle the request permission result.
If you are asking for Manifest.permission.ACCESS_BACKGROUND_LOCATION and Manifest.permission.ACCESS_FINE_LOCATION at the same time then android will call you on onRequestPermissionsResult with different set arguments depends of user response. In any case permissions argument will be the same:
["android.permission.ACCESS_BACKGROUND_LOCATION", "android.permission.ACCESS_FINE_LOCATION."]
Then if user allow "Only this time" or "While using.." you will receive in grantResults argument 0 (true) for ACCESS_FINE_LOCATION and -1 (false) for ACCESS_BACKGROUND_LOCATION:
[-1, 0]
But if user allow "all the time" you will receive:
[0, 0]
Finally is user "denies":
[-1, -1]
Again, the clue is yo know that allow "all the time" implies ACCESS_BACKGROUND_LOCATION grants.
ActivityCompat.requestPermissions(this, [Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION], 100)
...
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (grantResults[0] == PermissionChecker.PERMISSION_DENIED && grantResults[1] == PermissionChecker.PERMISSION_DENIED) {
// user denies
}
if (grantResults[0] == PermissionChecker.PERMISSION_DENIED && grantResults[1] == PermissionChecker.PERMISSION_GRANTED) {
// user allow while using
}
if (grantResults[0] == PermissionChecker.PERMISSION_GRANTED && grantResults[1] == PermissionChecker.PERMISSION_GRANTED) {
// user allow all the time
}
}