Data Usage on each API requestfrom the CommonsWare Community archives
At October 22, 2020, 2:12pm, arpit999 asked:
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(https://stackoverflow.com/questions/64470353/data-usage-each-api-consume)
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:
ViewModelfor holding onto in-use data, including user-modified data that you do not want to commit to a data store (database, server, etc.) yet
I recommend using a
DialogFragmentto manage your
When asking questions on Stack Overflow, if you provide code to illustrate a problem, explain what you are expecting the code to do and what the code is actually doing instead
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?