Last active
November 4, 2021 17:54
-
-
Save manuelvicnt/070c4d9c3d7e156343b719d210a7de8c 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) | |
// 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