Skip to content

Commit

Permalink
check background permission on each start
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterHasse committed Jul 24, 2024
1 parent 52e0e2f commit 248c3c9
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ private void requestPermission() {
}
}

// we can only request background after fine location. If that has failed on the first try we need to check again
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "Requesting ACCESS_BACKGROUND_LOCATION Permission");
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_BACKGROUND_LOCATION}, 3);
} else {
Log.d(TAG, "Got ACCESS_BACKGROUND_LOCATION Permission");
}
}


if (!permissions.isEmpty()) {
String[] perms = permissions.toArray(new String[0]);
ActivityCompat.requestPermissions(this, perms, 1337);
Expand Down

0 comments on commit 248c3c9

Please sign in to comment.