Is there any other way to find data usage in android other than using trafficstats API's

StackOverflow https://stackoverflow.com/questions/11789272

  •  24-06-2021
  •  | 
  •  

سؤال

In my application I want to calculate data usage when application is in foreground.

I am using Trafficstats API.

But some time this value get reset and start from 0.

Is there any other method or API to take data usage other than using Trafficstats which will never get reset.

Or is there any ways to track when that data gets reset?

هل كانت مفيدة؟

المحلول

My answer here is based on assumptions, and not on proven hard facts, but normally the counters in TrafficStats should not reset except for on reboot of the device. However, the data received from trafficStats are stored as long, and whenever the total value of the received/transmitted data exceeds the maximum capacity of a long, then it will appear as the stats have been reset as the long value will overflow.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top