Image for post
Image for post

So for those of you that followed me, I showed you a way to replace AsyncTask with Runnables in Java. At the end of the article, I suggested a to work with Rx java or coroutines before working with the solution I showed, which was kind of a band-aid solution because of demands at that time. Now I am going to give you the way to handle the same process of replacing AsyncTask with coroutines.

For the sake of understanding, I am going to use the same example a snippet from the last article I wrote that is the AsyncTask I want to…

Image for post
Image for post

If you are reading this because you just heard that starting from Android 11 AsyncTask is deprecated and you are looking for some kind of solution, you might have reached the right place.
This article is for you if you haven't moved to Kotlin you need some kind of Java solution.

Before we start I have to say that Kotlin offers the use of the amazing “coroutines” for asynchronous tasks. If you want to try it out you can do it with the following link. If you haven’t started working with Kotlin or at least reading about it I would really suggest starting doing so, since Google announced it as their official language for android development(!!). Not only that, but all of their documentation is also written in Kotlin for the new components (the old components have examples and documentation on Kotlin as well as Java) and if you are still not convinced — it reduces development times in average of about 40% which means less writing code, faster go-to-market time, it’s intuitively easy to read and has a lot of key features that I personally like as a developer. …


Idan Damri

Enthusiastic Android developer, as GEEK as they get..

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store