Skip to content

Instantly share code, notes, and snippets.

@Suchiq
Created August 1, 2022 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Suchiq/928ddf855e128d8996c3660b8c0ed49e to your computer and use it in GitHub Desktop.
Save Suchiq/928ddf855e128d8996c3660b8c0ed49e to your computer and use it in GitHub Desktop.
boolean permissionAccessCoarseLocationApproved =
ActivityCompat.checkSelfPermission(this,
permission.ACCESS_COARSE_LOCATION) ==
PackageManager.PERMISSION_GRANTED;
if (permissionAccessCoarseLocationApproved) {
// App has permission to access location in the foreground. Start your
// foreground service that has a foreground service type of "location".
} else {
// Make a request for foreground-only location access.
ActivityCompat.requestPermissions(this, new String[] {
Manifest.permission.ACCESS_COARSE_LOCATION},
your-permission-request-code);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment