Retrofit: How to wait for response

前端 未结 2 1710
故里飘歌
故里飘歌 2021-02-05 16:48

I have AsyncTask and the doInBackground method inside which, I sending POST request using Retrofit. My code looks like:

    //method of AsyncTask
    protected B         


        
2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 17:30

    "Retrofit sending request asynchronously" which as @Tanis.7x mentioned, enqueue() is doing the asynchronous, so what could be a reason to put in AsyncTask ? (async in async ?)

    You can simply put all retrofit code out from AsyncTask and onResponse is the callback that is waiting for your request call to be back, so you can do any UI update inside of this callback.

提交回复
热议问题