Are you aware with Asynchronous Programming? Well if you are into android application development, I am pretty sure that you know about Asynchronous Programming. And when you know what is Asynchronous Programming, you also know writing async codes are a kind of headache. But not anymore, here in this Kotlin Coroutines Tutorial for Android, I am going to show you magic 😉.
Yes you heard that right, I will show you magic. I will write asynchronous code, in synchronous manner. And I can do it with the help of Coroutines. When I left java and started using Kotlin for all my projects, I realized how awesome Kotlin is. And with Coroutines, it is just fabulous my friends. It makes writing network calls, and other async stuffs way more easier.
What is a Coroutine?
The very first question that arises in everyone’s mind. The official android developer page says,
“A coroutine is a concurrency design pattern that you can use on Android to simplify code that executes asynchronously. Coroutines were added to Kotlin in version 1.3 and are based on established concepts from other languages.”
Coroutine is basically a feature added from Kotlin Language 1.3 that super simplifies the asynchronous code.
Why use Coroutine?
We already had number of tools for async programming, then why we need Coroutine? Well this is a fair question that should be asked. We have RxJava, AsyncTask, Threads etc. Then why I should focus on learning a new concept?
But if you are using the above mentioned things, then you already know that how difficult it is to use RxJava correctly. The learning curve of RxJava is also too much. AsyncTask can easily introduce memory leaks in our app. Managing threads are another pain.
But with Coroutines all these shortcomings are fixed. Trust me guys, once you will start using it, you will understand how easy it is to learn and write.
Now, if you convinced you enough that you should learn Coroutines, and start using it in your projects, then let’s start the actual topic that was “Kotlin Coroutines Tutorial for Android”.
Kotlin Coroutines Tutorial for Android
In this playlist we will learn about using Kotlin Coroutines in our Android Project. Even if you are a beginner in android development you can go through this course. The only prerequisites are:
- You must know about using Kotlin Programming Language
- You must know how to use Retrofit to make network calls
It takes a lot of effort to make these courses for you. So I request you all that please help me by sharing my contents with your friends.
Download Source Code
You can get the source code of the project that I used in this Kotlin Coroutines Tutorial for Android here:
Thats all for this post friends. Please give your feedback below in the comment section. Don’t forget to share it with all your friends learning Android Application Development.
Hi, my name is Belal Khan and I am a Google Developers Expert (GDE) for Android. The passion of teaching made me create this blog. If you are an Android Developer, or you are learning about Android Development, then I can help you a lot with Simplified Coding.