3

I want to show the user how much internet data he consumed from 12am of that day till he checks, like the Datally app by google.

I know that we can see the total data usage after last reboot using TrafficStats class's getTotalRxBytes and getTotalTxBytes. That value resets in every reboot time. But I don't want want to reset the daily data usage even if the user reboots his device.

I searched for it all over the StackOverFlow, but failed to get an answer. I found so many ways to show data usage per app basis; I don't need them.

So, how can I able to show the daily total (Mobile + Wifi + Sent + Recieved) live data usage in my android application programmatically? If you have an answer, please tell me.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • @Stephen C Those answers from the links you mentioned above don't help me. There they answered about not reset the value at boot time and showing data usage per apps. But I need to show daily live data usage like google's Datally app. Thanks. – Md Rasel Hossain Nov 24 '19 at 03:32
  • 1
    My answer: you should be able to do this using NetworkStatsManager: see https://stackoverflow.com/questions/49107929/calculate-network-traffic-stats-of-app-during-a-month https://stackoverflow.com/questions/36702621/getting-mobile-data-usage-history-using-networkstatsmanager. Arrange that your app runs at the designated start of day to capture the total data usage. NetworkStatsManager can give you that info, then you do some arithmetic to work out usage since "yesterday". – Stephen C Nov 24 '19 at 04:16

0 Answers0