-1

I am using retrofit2 for making service call in my application, i need to show the progress percentage for the service call which is made using retrofit, the result of the call will be of some JSON object. we know that for downloading files we can use @Streaming and ResponseBody in retrofit for getting progress percent, but am unaware for the JSON response.

Example

@POST("/getdata")
fun callSomeApi(@Query("id") id : String) : Observable<Data>

Is there is any option to get progress percent for JSON response using retrofit ?
Any help

Stack
  • 1,164
  • 1
  • 13
  • 26
  • Check out this [SO Answer](https://stackoverflow.com/a/42119419/1889768) it goes in details on how to achieve just that. – Abbas May 03 '19 at 13:35

1 Answers1

0

For that purpose you need to use 'AsyncTask'. Because 'AsyncTask' is giving one of the way to update the progress of downloading.

protected void onProgressUpdate(Integer... progress) {
    setProgressPercent(progress[0]);
}

For api hitting you can hit the api from,

protected Long doInBackground(URL... urls) {

}
Ajay Mehta
  • 843
  • 5
  • 14
kundan kamal
  • 674
  • 7
  • 16