We may earn an affiliate commission when you visit our partners.
Lukas Lechner

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.

Read more

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

  • TestCoroutineDispatcher

  • creating a JUnit4 Rule for testing coroutine-based code

  • runBlockingTest{} Coroutine Builder

  • virtual time

  • Testing sequential and concurrent execution

  • TestCoroutineScope

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.

Enroll now

What's inside

Learning objectives

  • 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
  • Show more
  • Show less

Syllabus

Introduction
Extended Course Preview
Course Structure and Goals
How to get the source code of the Sample Project
Read more
Basic Setup of Sample Project
Studends will acquire a deep understanding about what problems Coroutines are trying to solve.
Section Introduction
What is Asynchronous Programming?
Use Case Explanation
Callback Implementation
RxJava Implementation
Coroutines Implementation
Comparing Approaches
Recap
Coroutine Fundamentals
Routines and Coroutines
Suspend Functions
Coroutines and Threads
Blocking VS Suspending
Multithreaded Coroutines
Internal Workings
How delay() works
Section Recap
UseCase Implementation
Performing Network Requests sequentially
Adding Coroutines to your project
Coroutine Builders: Launch and RunBlocking
Main-safety
Basic error handling with try-catch
Exercise 1
Exercise 1: Solution
Performing Network Requests concurrently
LifecycleScope
UseCase description
Implementing UseCase#3 in a sequential way
The async coroutine builder
Implementing UseCase#3 in a concurrent way
Implementing UseCase#4 in a sequential way
Exercise 2: Implementing UseCase#4 in a concurrent way
Exercise 2: Solution
Scoping Functions coroutineScope{} and supervisorScope{}
Higher-Order Functions
Implementing a timeout
Implementing retries
Extract retry logic into higher order function
Add exponential backoff to retry
Exercise 3: Combining retries and timeout
Exercise 3: Solution
Using Room with Coroutines
Background Processing with Coroutines
Continue Coroutine execution when the user leaves the screen
UseCase explanation
Implementation running on Main Thread
Coroutine Context
Coroutine Dispatchers
Using withContext for context switching
Coroutine Scope VS Coroutine Context
Exercise4: Perform calculation in several Coroutines
Exercise 4: Solution
Performance Analysis
Structured Concurrency and Coroutine Scopes
The unhappy path
Structured Concurrency
Coroutine Scopes
Building up the Job Hierarchy
Parents wait for Children
Cancellation of parent and child jobs
Job and SupervisorJob
Unstructured Concurrency
GlobalScope
ViewModelScope
Coroutines Cancellation
Cancelling Coroutines
Cooperative Cancellation
NonCancellable Code
Making UseCase10 cooperative regarding cancellation
Coroutines Exception Handling
Exception Handling with try-catch
Coroutine Exception Handler
Try-Catch VS Coroutine Exception Handler
launch{} VS async{}
Exception Handling specifics of coroutineScope{}
Exception Handling specifics of supervisorScope{}
Implementation of UseCase13 with try-catch
Implementation of UseCase13 with CoroutineExceptionHandler

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Recommended by Google, this course teaches Kotlin Coroutines and Flow, which are the preferred solutions for asynchronous programming on Android
Explores exception handling in Coroutines with try/catch and CoroutineExceptionHandlers, which is essential for robust Android development
Covers unit testing for coroutine-based implementations, including TestCoroutineDispatcher and runBlockingTest{}, which are critical for ensuring code quality
Teaches how to use Room with Coroutines, which is a common pattern in Android development for data persistence
Requires a solid understanding of Coroutines before diving into Flows, so learners may need to dedicate extra time to the first part

Save this course

Save Kotlin Coroutines and Flow for Android Development to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Kotlin Coroutines and Flow for Android Development with these activities:
Review Kotlin Fundamentals
Solidify your understanding of Kotlin syntax and core concepts before diving into coroutines and flows. This will make it easier to grasp the more advanced asynchronous programming techniques.
Show steps
  • Review Kotlin documentation on variables, functions, and classes.
  • Practice writing simple Kotlin programs.
  • Complete online Kotlin tutorials or exercises.
Read 'Kotlin in Action'
Gain a deeper understanding of Kotlin's features and how they apply to Android development. This book will provide a solid foundation for understanding coroutines and flows.
Show steps
  • Read the chapters relevant to Kotlin's core language features.
  • Work through the examples and exercises in the book.
  • Take notes on key concepts and syntax.
Practice Asynchronous Operations with Callbacks
Gain familiarity with asynchronous programming using callbacks before learning coroutines. This will help you appreciate the benefits of coroutines and flows.
Show steps
  • Implement asynchronous tasks using callbacks in Kotlin.
  • Simulate network requests or background processing with delays.
  • Handle errors and exceptions in your callback implementations.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Follow Android Coroutines Tutorials
Reinforce your understanding of coroutines by following practical tutorials. This will help you see how coroutines are used in real-world Android applications.
Show steps
  • Search for Android coroutines tutorials on the internet.
  • Follow the tutorials step-by-step, implementing the code examples.
  • Experiment with different coroutine builders and operators.
Build a Simple Android App with Coroutines and Flow
Apply your knowledge of coroutines and flows by building a small Android application. This will solidify your understanding and give you practical experience.
Show steps
  • Design a simple Android app that uses coroutines and flows.
  • Implement the app's features using coroutines and flows.
  • Test the app thoroughly to ensure it works correctly.
Write a Blog Post on Kotlin Coroutines and Flow
Deepen your understanding by explaining coroutines and flows to others. Writing a blog post will force you to organize your thoughts and clarify any remaining questions.
Show steps
  • Choose a specific topic related to coroutines and flows.
  • Research the topic thoroughly and gather information.
  • Write a clear and concise blog post explaining the topic.
  • Include code examples and diagrams to illustrate your points.
Contribute to a Kotlin Coroutines Library
Gain advanced experience by contributing to an open-source Kotlin coroutines library. This will expose you to real-world code and best practices.
Show steps
  • Find an open-source Kotlin coroutines library on GitHub.
  • Browse the library's issues and find a bug to fix or a feature to implement.
  • Submit a pull request with your changes.

Career center

Learners who complete Kotlin Coroutines and Flow for Android Development will develop knowledge and skills that may be useful to these careers:
Android Application Developer
An Android application developer is responsible for creating, testing, and maintaining applications for the Android platform. This course on Kotlin Coroutines and Flow is essential because they are the recommended solution for asynchronous programming on Android. The course's detailed explanations of coroutine concepts, such as structured concurrency, coroutine scopes, and exception handling, help to build a strong foundation. A developer will find the practical use cases and exercises invaluable for hands-on experience. This course is useful for any developer specializing in Android application development.
Android Developer
An Android developer builds applications for the Android operating system, often working with Kotlin. This course on Kotlin Coroutines and Flow directly aligns with the asynchronous programming techniques used in modern Android development. The course provides hands-on experience with use cases such as performing network requests, using Room with coroutines, and handling background processing. An Android developer will find the lessons on coroutine builders, dispatchers, and exception handling especially helpful. This course is designed for those looking to build advanced Android applications.
Mobile Software Developer
A mobile software developer specializes in creating applications for mobile platforms such as Android. This course on Kotlin Coroutines and Flow is directly relevant to a mobile software developer who builds Android applications, where coroutines and flows are the preferred approach for asynchronous programming. The course covers key topics such as coroutine builders, dispatchers, and exception handling, all of which are directly applicable to building robust applications. A mobile software developer will find the practical use cases particularly beneficial. This course is ideal for those focusing on Android development.
Mobile Application Developer
Mobile application developers create apps for mobile devices, and this course in Kotlin Coroutines and Flow helps build a foundation for building high-performance Android apps. The course focuses specifically on how to manage asynchronous operations efficiently. A mobile application developer will find the course valuable due to its focus on real-world use cases such as network requests and database interactions. The course's discussions on coroutine context, cancellation, and testing enhance a developer's ability to build clean, robust mobile applications. This course is especially useful for those wishing to specialize in Android development.
Mobile Architect
A mobile architect is responsible for the overall structure and design of mobile applications. This course on Kotlin Coroutines and Flow provides essential building blocks for designing performant Android applications. A mobile architect will find the deep dive into structured concurrency, coroutine scopes, and exception handling highly relevant. The practical knowledge gained from this course helps a mobile architect in creating robust and maintainable architectures. This course is particularly valuable for architects designing complex Android applications.
Application Engineer
An application engineer is responsible for the development, maintenance, and testing of applications. This course on Kotlin Coroutines and Flow prepares one to implement modern, efficient applications on Android. An application engineer will find this course very helpful because it provides hands-on experience and in-depth knowledge. Lessons on performing network requests, using Room, and background processing are directly applicable. The course goes into important concepts like structured concurrency and exception handling. This course is particularly helpful for an application engineer in an Android environment.
Software Development Engineer
A software development engineer is involved in the full lifecycle of software development. This course on Kotlin Coroutines and Flow may be useful to an engineer who wishes to specialize in Android development. The course discusses coroutines and flows, which are essential for building responsive and efficient Android applications. A software development engineer will find the discussions on testing and exception handling particularly helpful in creating robust code. The lessons in use cases such as handling network requests are immediately applicable. This course is recommended for software development engineers working on Android.
Software Engineer
A software engineer designs, develops, and tests software systems. This course on Kotlin Coroutines and Flow may be useful because it focuses on concurrent and asynchronous programming that are essential skills in modern software development. The course teaches how to use coroutines effectively, covering a wide range of topics, such as coroutine builders, dispatchers, and exception handling. A software engineer will find this knowledge directly applicable to building more responsive and efficient applications for the Android platform. This course may be helpful for those working on Android applications.
Technical Lead
A technical lead guides and manages software development teams. This course on Kotlin Coroutines and Flow may be useful to a technical lead who needs to understand the technical aspects of Android development. Understanding the intricacies of coroutines, flows, and asynchronous programming helps a technical lead guide their team more effectively. The course's deep dive into practical use cases and best practices means a technical lead can appreciate trade-offs and make informed decisions. A technical lead who wishes to guide an Android development team in particular may find this course helpful.
Backend Developer
Backend developers build the server-side components of applications, and although this course is specific to Android, the concepts of asynchronous programming and concurrency taught are broadly applicable to any backend system. While a backend developer may not use Kotlin or Android directly in their daily work, the course can be useful to understand concurrency patterns. Lessons on exception handling and testing are helpful for producing robust backend systems. A backend developer may benefit from the theoretical foundations that are taught in this course.
Platform Engineer
A platform engineer builds and maintains the underlying infrastructure for software applications. This course on Kotlin Coroutines and Flow may be useful due to its focus on asynchronous programming. Though specific to Android, the concepts of managing concurrency taught in this course help a platform engineer understand how to build scalable systems. The course's discussion of topics like exception handling and cancellation also benefit a platform engineer developing robust systems. This course may be useful in learning more about concurrency and resource usage, especially on mobile.
Software Development Manager
A software development manager oversees the development process of software projects. This course on Kotlin Coroutines and Flow may be useful for a manager to understand how their Android development team is dealing with asynchronous programming. While the manager may not directly write code, an understanding of asynchronous programming via Kotlin coroutines and flows allows them to make better decisions. The course's focus on practical application of coroutines may be particularly helpful for a software development manager to evaluate schedules and milestones. This course may be useful to a manager of Android teams in particular.
Systems Architect
A systems architect is responsible for designing the overall structure of a software system. While this course focuses on Android asynchronous programming with Kotlin, the concepts of concurrency and efficient resource usage are broadly applicable to many software systems. A systems architect might find this course useful for understanding how asynchronous operations can be handled, which is a common concern in many distributed systems. The course's coverage of exception handling and cancellation also offers insights into creating more resilient systems. A systems architect might find this course helpful in expanding their understanding of concurrency.
Quality Assurance Engineer
A quality assurance engineer ensures that software meets quality standards. This course on Kotlin Coroutines and Flow may be useful to a QA engineer, especially one focusing on Android applications. The course can help the engineer understand the complexities of asynchronous programming and concurrency, which are crucial to identify and debug issues. Unit testing is covered in depth in the course, which is directly applicable for writing tests that will help prevent bugs. The QA engineer may find the course useful in deepening their understanding of the code they are testing.
Embedded Systems Engineer
An embedded systems engineer designs and develops software for embedded systems, which often includes mobile devices. This course on Kotlin Coroutines and Flow could be helpful for managing asynchronous operations on Android-based embedded systems. The course introduces how to handle concurrency and exception handling. An embedded systems engineer will find the sections on multithreading, cancellation, and performance analysis useful. This course may be helpful as an introduction to Android-related programming patterns.

Reading list

We've selected one books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Kotlin Coroutines and Flow for Android Development.
Provides a comprehensive guide to Kotlin, covering everything from basic syntax to advanced features. It's particularly helpful for understanding the nuances of Kotlin that are relevant to Android development. The book also provides a solid foundation for understanding coroutines and flows, which are essential for asynchronous programming in Android. It is commonly used as a textbook at academic institutions.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser