Kotlin Coroutines and Flow for Android Development [2026]

The Complete Guide! Get a deep understanding of Kotlin Coroutines and Flow to use them successfully in your Android Apps

  • 0.0 (0 Reviews)
  • 0 Students
  • 159 Lessons
  • Lukas Lechner

Course Overview

Google recommends Kotlin Coroutines and Flow as the preferred solution for asynchronous programming on Android. Sooner or later, probably every  Android developer will get in touch with these topics.


This course will give you a deep understanding of Kotlin Coroutines and Flow and show how to implement the most common use cases for Android applications.


This course consists of two big parts: The Coroutines part and the Flow part.

Before being able to use Flows in our applications, we first need a solid understanding of Coroutines. That’s why Coroutines are covered first. However, if you already have some experience with Coroutines, then you can also start with the Flow part right away, and jump back to lessons of the Coroutines part whenever needed.


In the part about Coroutines, first, we will take a detailed look at the advantages of Kotlin Coroutines over other approaches for asynchronous programming, like RxJava and Callbacks.


Then, we will talk about some theoretical fundamentals. These include:

  • Routines vs. Coroutines

  • Suspend Functions

  • Coroutines vs. Threads

  • Blocking vs. Suspending

  • Multithreaded Coroutines

  • Internal workings


Next, we will implement some of the most common use cases for Kotlin Coroutines in Android applications. These include: 

  • Performing network requests with Retrofit sequentially and concurrently

  • Implementing Timeouts and Retries

  • Using Room with Coroutines

  • Performing background processing with Coroutines

  • Continuing Coroutine execution even when the user leaves the screen.


To improve your learning experience, this course also challenges you with several exercises.


Learning Coroutines can be overwhelming because you need to learn a lot of new concepts. However, we are going to start simple and as our use cases will get more and more complex, we will learn about new concepts step-by-step. These new concepts are:

  • Coroutine Builders (launch, async, runBlocking)

  • Coroutine Context

  • Coroutine Dispatchers

  • Structured Concurrency

  • Coroutine Scopes (viewModelScope, lifecycleScope, GlobalScope)

  • Jobs and SupervisorJobs

  • scoping functions (coroutineScope{} and supervisorScope{})

  • Cooperative Cancellation

  • Non-Cancellable Code


We will also make a deep dive into Exception Handling and discuss concepts like: 

  • exception handling with try/catch

  • exception handling with CoroutineExceptionHandlers

  • when to use try/catch and when to use a CoroutineExceptionHandler

  • exception handling in Coroutines started with launch and async

  • exception handling specifics of scoping functions coroutineScope{} and supervisorScope{}


Unit Tests are very important for every codebase. In the course's final section, we will write unit tests for most of the coroutine-based use cases we implemented earlier. We will discuss concepts like

  • TestDispatchers (StandardTestDispatcher, UnconfinedTestDispatcher)

  • Creating a JUnit4 Rule for testing coroutine-based code

  • runTest{} Coroutine Builder

  • virtual time

  • Testing sequential and concurrent execution

  • TestScopes

  • Updated coroutine testing module using the latest APIs (2026)


In the part about Kotlin Flow, we first cover all the basics. We will answer the question “What is a Flow?” and then we discuss the benefits and drawbacks of reactive programming.


Afterward, we are going to have a look at different Flow builders and operators:

  • basic flow builders

  • terminal operators

  • terminal operator “launchIn()”

  • terminal operator “asLiveData()”

  • lifecycle operators

  • intermediate operators


In our first real Flow use case, we use a Flow to create a live stock-tracking feature, that uses all the available basic flow components.


In the next module, we will take a look at Exception Handling and Cancellation with Kotlin Flow.


In the following module, you will learn about StateFlow and SharedFlow and the following concepts:

  • how to make Coroutines lifecycle-aware with the “repeatOnLifecycle()” suspend function

  • Hot Flows VS Cold Flows

  • Converting Flows to SharedFlows with the “shareIn()” operator

  • Converting Flows to StateFlows with the “stateIn()” operator

  • When to use SharedFlow and when to use StateFlow


Next, you will learn about Channels, how they differ from hot flows, and when they are useful in Android Applications.


By the end of this course, you will have a fundamental understanding of Kotlin Coroutines and Flows and be able to write readable and maintainable, asynchronous, and multithreaded Android Applications.

See more

FAQ

FAQ area empty

Course curriculum

18 chương 159 bài học 16 giờ 15 phút 7 bài học thử miễn phí
Chương 1 Introduction
Chương 2 Different Approaches for Asynchronous Programming
Chương 3 Coroutine Fundamentals
  • Section Introduction 1:39
  • Important Information about Playground functions
  • Routines and Coroutines 7:14
  • Suspend Functions 4:09
  • Coroutines and Threads 7:12
  • Blocking VS Suspending 7:21
  • Multithreaded Coroutines 3:24
  • Internal Workings 6:24
  • How delay() works 7:48
  • Section Recap 2:47
Chương 4 Performing Network Requests sequentially
  • Introduction 1:08
  • Adding Coroutines to your project 2:20
  • Coroutine Builders: Launch and RunBlocking 18:28
  • Main-safety 2:34
  • Basic error handling with try-catch 3:15
  • Exercise 1 2:30
  • Exercise 1: Solution 1:55
  • Section Recap 2:34
Chương 5 Performing Network Requests concurrently
  • Section Introduction 1:05
  • UseCase description 2:25
  • Implementing UseCase#3 in a sequential way 4:57
  • The async coroutine builder 13:59
  • Implementing UseCase#3 in a concurrent way 7:42
  • Implementing UseCase#4 in a sequential way 5:10
  • Exercise 2: Implementing UseCase#4 in a concurrent way 1:07
  • Exercise 2: Solution 4:19
  • Section Recap 1:27
Chương 6 Higher-Order Functions
  • Implementing a timeout 8:43
  • Implementing retries 4:27
  • Extract retry logic into higher order function 7:02
  • Add exponential backoff to retry 4:52
  • Exercise 3: Combining retries and timeout 1:42
  • Exercise 3: Solution 3:45
  • Section Recap 1:01
Chương 7 Using Room with Coroutines
  • Section Introduction 1:23
  • UseCase description 3:12
  • UseCase Implementation 13:14
  • Section Recap 1:04
Chương 8 Background Processing with Coroutines
  • Section Introduction 1:05
  • UseCase explanation 1:46
  • Implementation running on Main Thread 6:27
  • Coroutine Context 4:54
  • Coroutine Dispatchers 6:48
  • Using withContext for context switching 10:57
  • Coroutine Scope VS Coroutine Context 2:07
  • Exercise4: Perform calculation in several Coroutines 7:15
  • Exercise 4: Solution 7:00
  • Performance Analysis 1:56
  • Section Recap 2:31
Chương 9 Structured Concurrency and Coroutine Scopes
  • Section Introduction 1:41
  • The unhappy path 3:00
  • Structured Concurrency 8:26
  • Coroutine Scopes 5:09
  • Building up the Job Hierarchy 11:14
  • Parents wait for Children 2:15
  • Cancellation of parent and child jobs 5:26
  • Job and SupervisorJob 5:28
  • Unstructured Concurrency 4:45
  • GlobalScope 3:48
  • ViewModelScope 8:24
  • LifecycleScope 3:08
  • Scoping Functions coroutineScope{} and supervisorScope{} 9:49
  • Continue Coroutine execution when the user leaves the screen 12:19
  • Section Recap 5:04
Chương 10 Coroutines Cancellation
  • Cancelling Coroutines 5:03
  • Cooperative Cancellation 6:02
  • NonCancellable Code 2:11
  • Making UseCase10 cooperative regarding cancellation 4:53
  • Section Recap 2:34
Chương 11 Coroutines Exception Handling
  • Section Introduction 2:14
  • Exception Handling with try-catch 8:41
  • Coroutine Exception Handler 5:30
  • Try-Catch VS Coroutine Exception Handler 5:48
  • Launch{} VS async{} 7:28
  • Exception Handling specifics of coroutineScope{} 3:35
  • Exception Handling specifics of supervisorScope{} 9:32
  • Implementation of UseCase13 with try-catch 4:30
  • Implementation of UseCase13 with CoroutineExceptionHandler 2:51
  • Implementation of UseCase13 - show results even if a child coroutine fails 11:53
  • Rethrowing CancellationExceptions 2:19
  • Coroutines Exception Handling Cheat Sheet
  • Conference Talk: Exception Handling in Kotlin Coroutines
  • Section Recap 3:42
Chương 12 Testing Coroutines
  • Section Introduction 2:09
  • General Unit Testing Approach 3:02
  • Basic Test Setup 14:08
  • TestCoroutineDispatchers 6:57
  • Testing the unhappy path 3:41
  • Creating a JUnit4 Rule for Testing Coroutine-based code 5:40
  • Excercise 5: Create a Unit Test for UseCase2 1:22
  • Solution: Exercise 5 4:56
  • RunTest{} Coroutine Builder 9:50
  • Virtual Time 10:22
  • Testing sequential and concurrent execution 9:23
  • Testing Timeouts (UseCase5) and Retries (UseCase 6) 0:50
  • Testing implementations that use Dispatchers.Default or Dispatchers.IO 6:05
  • TestScope and Controlling Coroutine Execution 12:45
  • Section Recap 3:16
Chương 13 Basics of Kotlin Flow
  • Section Introduction 2:04
  • What is a Flow? 14:38
  • Reactive Programming 3:43
  • Starting our first Flow Use Case 9:45
  • Basic Flow Builders 12:38
  • Exposing a Flow in our DataSource 7:14
  • Displaying the stock list on the screen 2:54
  • Basic Terminal operators 17:17
  • Terminal operator "launchIn()" 9:05
  • Using "launchIn()" in UseCase1 2:15
  • Lifecycle Operators 14:45
  • Terminal operator "asLiveData()" 23:52
  • Basic Intermediate Operators 18:14
  • Exercise: Intermediate Operators 4:40
  • Exercise Solution 16:06
  • Section Recap 5:43
  • Slides of the Section
Chương 14 Flow Exception Handling and Cancellation
  • Flow Exception Handling 19:46
  • Exception Transparency 10:28
  • The "retry()" Operator 10:33
  • Exercise: Flow Exception Handling 5:01
  • Exercise Solution 5:54
  • Flow Cancellation 21:38
  • Slides of the Section
Chương 15 StateFlow and SharedFlow
  • Exposing Flows instead of LiveData in the ViewModel 5:45
  • Naive Approach - Exposing regular Flows 8:35
  • Lifecycle-aware Coroutines with "repeatOnLifecycle()" 12:44
  • Flows are cold 6:22
  • SharedFlows are hot 9:44
  • Converting Flows to SharedFlows with "shareIn()" 12:56
  • Keeping the upstream Flow alive during configuration changes 8:10
  • The "replay" parameter 5:48
  • StateFlow 9:26
  • Converting Flows to StateFlows with "stateIn()" 3:06
  • SharedFlow VS StateFlow 4:44
  • Section Recap 6:10
  • Slides of the Section
Chương 16 Channels
  • Channels for Android Development 10:38
  • Single UI Events
  • Slides of the Section
Chương 17 Concurrent Flows
  • Important Information
  • The buffer() operator 11:00
  • Dealing with Backpressure (aka BufferOverflow) 13:22
  • CollectLatest(), mapLatest() and transformLatest() 6:22
  • The conflate() operator 3:03
  • Buffers in SharedFlows and StateFlows 11:09
  • Slides of the Section
Chương 18 Thank you and Bonus
  • Bonus: Get my other courses with a nice discount!
  • Thank you and Bonus 1:31

Requirment

  • No prior knowledge about Kotlin Coroutines or Flow needed, however you should be familiar with the Basics of Kotlin and Android, as well as some Android Jetpack Components (ViewModels, LiveData, Room) and Retrofit.

Outcomes

  • Implement the most common use cases for Kotlin Coroutines and Flow on Android

  • Get a deep understanding of Kotlin Coroutines and Flows

  • Learn advanced Coroutine Concepts (Structured Concurrency, Coroutine Scopes and Contexts, internal workings, )

  • Learn how to create Flows using different Flow builders

  • Learn about Flow operators (lifecycle operators, intermediate operators, terminal operators)

  • Learn about different kind of Flows (regular Flows, SharedFlows, StateFlows)

  • Create a stock live-tracking app with Flows

  • Learn when to use Channels in Android Development

  • Understand the advantages of using Coroutines over Callbacks or RxJava.

  • How to perform network requests with Retrofit sequentially and concurrently.

  • How to use Room together with Coroutines.

  • Background processing with Coroutines.

  • Exception Handling and Cancellation in Coroutines and Flows.

  • How to write Unit Tests for coroutine-based implementations

Instructor

...
Lukas Lechner

0.0

  • ... 0 Student
  • ... 1 Course
  • ... 0 review

View Details

Reviews

Rate this course :

Remove all