Member-only story
Coroutines Cheat Sheet for Android Developers

Hola, you lovely devs! 👩🏻💻
Welcome to yet another blog of our ongoing Android Interview Prep series. In this blog, we’ll be discussing about a really important concept in Android: Kotlin Coroutines. This coroutine cheat sheet serves as a quick refresher for anyone familiar with this powerful tool.
And here’s a special treat for our non-Medium members: we’re offering free access to this blog! Just follow this link — because your curiosity and passion for coding should never be limited! 😉😉
Let’s get the party started…
- Launching a Coroutine (
launch
)
launch
is used to start a coroutine without expecting a result.- It’s usually used when you just want to fire and forget a task.
Example Usage:

2. Getting a Result with async
- If you need a result from a coroutine,
async
is your friend. async
returns aDeferred
object, which you canawait
to get the result.
🐼️Deferred
is a type of coroutine job that holds a result, and you can retrieve this result asynchronously.
🐼 To get the result, you use await()
, which suspends (pauses) the coroutine until the result is available.

⭐️ Bonus ⭐ ️
A coroutine job represent the lifecycle of a single coroutine. It controls the coroutine’s execution (starting a coroutine), cancelling a coroutine or checking its status i.e. if it’s active or not. Every coroutine has a
Job
object, which you can use to manage it.

In this example, the job
controls the coroutine. After 500ms, the job is canceled, and the coroutine doesn't complete.