Sitemap
Mobile App Development Publication

Sharing iOS, Android and relevant Mobile App Development Technology and Learning

Member-only story

Learning Android Development

Understand Android Lifecycle Aware Coroutine Scope Made Easy

Manage lifecycle more elegantly with Android provided Coroutine Scopes

4 min readDec 27, 2021

--

Photo by Minnie Zhou on Unsplash

To use Kotlin Coroutine, we need to have the appropriate scope defined. The tricky bit of it is, we have to remember to create, and stop them. In view of that, the Google Android development team has provided us with some Coroutine Scopes that are aware of its lifecycle.

Below, I’ll try to illustrate them below so that one can easily understand them.

In the examples, when I use lifecycleScope for Activity, it is viewLifecycleOwner.lifecycleScope for Fragment.

To learn specifically on Fragment check out

1. Repeat (restart) the Coroutine Scope Every Time on Specific Lifecycle

Sometimes we need to have some function executed whenever we are in a specific lifecycle and stop immediately when outside the lifecycle stage, e.g…

--

--

Mobile App Development Publication
Mobile App Development Publication

Published in Mobile App Development Publication

Sharing iOS, Android and relevant Mobile App Development Technology and Learning

Elye - A One Eye Dev By His Grace
Elye - A One Eye Dev By His Grace

Written by Elye - A One Eye Dev By His Grace

Sharing Software, Life and Faith Journey. Follow me on Twitter/X to access to my article free

Responses (1)