Reputation: 45
Is AsyncTask
still needed?
In Android with Java, we used to implement an AsyncTask
and AsyncTaskLoader
, but recently I've been beginning to learn Kotlin and I've noticed that things like that are done by Kotlin Coroutines.
Upvotes: 3
Views: 1187
Reputation: 10507
AsyncTask
has been officially deprecated since Android 11.
https://developer.android.com/reference/android/os/AsyncTask
Coroutines are the recommended choice, and considering Kotlin is the official language since 2017, then using AsyncTask
is no longer a standard option.
Upvotes: 7
Reputation: 988
Yes, you use Kotlin Coroutines to perform async operations now.
If you are looking for Coroutine usage, then here is an example of using Coroutines to fetch data from different sources asynchronously:-
https://codingnconcepts.com/kotlin/fetch-data-from-sources-async/
Upvotes: 1