Skip to content

Instantly share code, notes, and snippets.

@psteiger
Last active November 20, 2020 03:49
Show Gist options
  • Select an option

  • Save psteiger/312c138c68ed90ae1367c0df0564e15a to your computer and use it in GitHub Desktop.

Select an option

Save psteiger/312c138c68ed90ae1367c0df0564e15a to your computer and use it in GitHub Desktop.
LocationFetcher library usage example
class MyActivity : AppCompatActivity() {
private val locationFetcher: LocationFetcher by lazy {
LocationFetcher.create(this)
}
override fun onCreate(savedInstanceState: Bundle?) {
with (locationFetcher) {
location
.onEach { /* Location received */ }
.launchIn(lifecycleScope)
settingsStatus
.onEach { /* Location enabled/disabled in device settings */ }
.launchIn(lifecycleScope)
permissionStatus
.onEach { /* Access to device's location allowed/disallowed */ }
.launchIn(lifecycleScope)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment