Created
March 23, 2021 06:50
-
-
Save manuelvicnt/00222456423cbe1bf5cca2cb73d2db88 to your computer and use it in GitHub Desktop.
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 LocationActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// Collects from the flow when the lifecycle is at least STARTED and | |
// STOPS the collection when it's STOPPED. | |
// It automatically restarts collecting when the lifecycle is STARTED again. | |
lifecycleOwner.addRepeatingJob(Lifecycle.State.STARTED) { | |
locationProvider.locationFlow().collect { | |
// New location! Update the map | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment