Last active
November 20, 2020 03:49
-
-
Save psteiger/312c138c68ed90ae1367c0df0564e15a to your computer and use it in GitHub Desktop.
LocationFetcher library usage example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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