Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Retrofit with AsyncTask?

Few days ago when I tried to learn how to use Retrofit, I found some tutorials that says on some occassions, we should use ASyncTask together with Retrofit. This puzzles me because my impression was we use Retrofit to avoid using ASyncTask. And now I've understood Retrofit quite well (enough to use it and change all my ASyncTask codes to Retrofit), I still haven't find a good excuse or reason to use ASyncTask with Retrofit. Or am I missing anything here?

Btw I saw at least 3 different tutorials that mention on using Retrofit with ASyncTask, but I couldn't find it anymore. I could only find 1, http://karanbalkar.com/2014/12/tutorial-94-using-retrofit-for-android/

like image 544
imin Avatar asked Sep 16 '15 15:09

imin


1 Answers

The cited tutorial uses synchronous calls. For synchronous calls it makes sense to put them into an AsyncTask.

However, since Retrofit also supports asynchronous calls, it is easier to use them directly without an AsyncTask.

like image 108
Henry Avatar answered Sep 29 '22 17:09

Henry