Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Last active November 4, 2021 17:54
Show Gist options
  • Save manuelvicnt/070c4d9c3d7e156343b719d210a7de8c to your computer and use it in GitHub Desktop.
Save manuelvicnt/070c4d9c3d7e156343b719d210a7de8c to your computer and use it in GitHub Desktop.
class LocationActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Create a coroutine
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
// Repeat when the lifecycle is RESUMED, cancel when PAUSED
}
// `lifecycle` is DESTROYED when the coroutine resumes. repeatOnLifecycle
// suspends the execution of the coroutine until the lifecycle is DESTROYED.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment