LocationPermissionService

Service to check and request location permissions.

Constructors

Link copied to clipboard
constructor(activity: AppCompatActivity, onLocationPermissionRequestResultListener: LocationPermissionService.OnLocationPermissionRequestResultListener? = null)

Constructor. This constructor must be used when actions requiring a UI are needed, such as when requesting permissions.

constructor(context: Context, onLocationPermissionRequestResultListener: LocationPermissionService.OnLocationPermissionRequestResultListener? = null)

Constructor. This constructor can be used if only permissions must be checked but not be requested.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class LocationPermissionResult(val cancelled: Boolean = true, val finePermissionGranted: Boolean = false, val coarsePermissionGranted: Boolean = false, val backgroundPermissionGranted: Boolean = false, val finePermissionRequested: Boolean = false, val coarsePermissionRequested: Boolean = false, val backgroundPermissionRequested: Boolean = false)

Contains information about the result of location permission request.

Listener to notify the result of permission request.

Properties

Link copied to clipboard

activity where this service is instantiated from. Might not be available if this is instantiated somewhere else, such as a service. When activity is available, actions requiring a UI, such as requesting permission, can be used.

Link copied to clipboard

context where this service is instantiated from. This is used to check permissions only.

Functions

Link copied to clipboard

Indicates whether application has background location permission. Background location permission must be requested along with either fine or coarse location permission. Background location permission is only supported for SDK 29 or greater. For older Android versions, whenever fine or location permission is granted, background location permission is also assumed to be granted as well.

Link copied to clipboard

Indicates whether application has coarse location permission.

Link copied to clipboard

Indicates whether application has fine location permission. When fine location permission is granted, coarse permission is also implicitly granted.

Requests coarse location permission in background. Whenever background permission is granted, foreground permission is also implicitly granted.

Link copied to clipboard

Requests fine location permission in background. Whenever fine location permission is granted, coarse permission is also implicitly granted. Additionally, whenever background permission is granted, foreground permission is also implicitly granted.

Link copied to clipboard

Requests coarse location permission in foreground. If background location permission is also needed, then requestBackgroundCoarseLocationPermission must be used instead.

Link copied to clipboard

Requests fine location permission in foreground. If background location permission is also needed, then requestBackgroundFineLocationPermission must be used instead. Whenever fine location permission is granted, coarse permission is also implicitly granted.

Indicates whether a rationale should be displayed to the user indicating why background location permission is needed. This is true if the user chooses not to be asked again about background location permission and denies such permission.

Indicates whether a rationale should be displayed to the user indicating why coarse location permission is needed. This is true if the user chooses not be asked again about coarse location permission and denies such permission.

Indicates whether a rationale should be displayed to the user indicating why fine location permission is needed. This is true if the user chooses not to be asked again about fine location permission and denies such permission.