Skip to content

Instantly share code, notes, and snippets.

@RaheemJnr
Created April 11, 2023 14:55
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 RaheemJnr/fb792bddf6d2124dcc2626a5edbaad9b to your computer and use it in GitHub Desktop.
Save RaheemJnr/fb792bddf6d2124dcc2626a5edbaad9b to your computer and use it in GitHub Desktop.
@SuppressLint("MissingPermission")
fun locationUpdate() {
locationCallback.let {
//An encapsulation of various parameters for requesting
// location through FusedLocationProviderClient.
val locationRequest: LocationRequest =
LocationRequest.create().apply {
interval = TimeUnit.SECONDS.toMillis(60)
fastestInterval = TimeUnit.SECONDS.toMillis(30)
maxWaitTime = TimeUnit.MINUTES.toMillis(2)
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
}
//use FusedLocationProviderClient to request location update
locationProvider.requestLocationUpdates(
locationRequest,
it,
Looper.getMainLooper()
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment