Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloody-Badboy committed Jul 11, 2021
1 parent 5d1e560 commit c7caaf1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ A library to request location update for both GMS and HMS with less boilerplate

# Usages
Create `LocationRequest` object
```kotlin
private val locationRequest = LocationRequest().apply {
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
interval = 20000L
fastestInterval = 10000L
}
```

Initialize `LocationFetcher` in your activity or fragment
```kotlin
private val fetcher: LocationFetcher by lazy {
LocationFetcher(
context = this,
updateInterval = 4000L, // location update interval
locationReceiver = object : LocationReceiver {
request = locationRequest, // location request
receiver = object : LocationReceiver {
override fun onReceived(location: Location) {
// TODO: do something with location
}
Expand All @@ -26,7 +33,11 @@ Initialize `LocationFetcher` in your activity or fragment

Start `LocationSettingsActivity` to check location permission and device GPS settings to request location update
```kotlin
startActivityForResult(Intent(this, LocationSettingsActivity::class.java), 100)
startActivityForResult(
LocationSettingsActivity.buildIntent(
this,
locationRequest
), 100)
```

check the result in `onActivityResult` and start location update
Expand Down

0 comments on commit c7caaf1

Please sign in to comment.