Data Usage on each API request

from the CommonsWare Community archives

At October 22, 2020, 2:12pm, arpit999 asked:

Hi Mark,
Hope you are well.

I am working on a project where I am requesting 5 different requests on the server every 2 seconds. I would like to know how much data I am using in every request. I know about the profiler in Android Studio but it does not give me the data usage for each API request.

I search on google but could not find anything.

Please suggest any tool or reference. Here is [SO Question] I post(

At October 22, 2020, 3:19pm, mmurphy replied:

If you are asking how you can measure this as a developer on your development machine, if you are using OkHttp (or things built atop it, such as Retrofit), you could use the OkHttp logging interceptor, Flipper, etc.

If you are asking how you can measure this at runtime for requests on user devices, and you are using OkHttp, you could write your own custom OkHttp interceptor that records this information and reports it via your preferred solution for that sort of thing (e.g., analytics).

At October 22, 2020, 3:25pm, arpit999 replied:

Thanks, Mark for the quick prompt. I am using the Okhttp3 with AsyncTask and I want to measure how much data each API use for a certain duration. Could you please provide an example or link?

At October 22, 2020, 3:52pm, mmurphy replied:

Sorry, but I do not know what to give you beyond what I did in my previous reply.

At October 22, 2020, 3:54pm, arpit999 replied:

Ok, thank you for your help. Can you help with this question?

At October 22, 2020, 4:15pm, mmurphy replied:

Sorry, but I do not understand that question. In general:

At October 22, 2020, 5:25pm, arpit999 replied:

Ok, I will improve the question. Thank you for the suggestion.

Are you providing any rxJava materials? Can you please suggest the best place to learn rxJava?