We want to create a function that measures data usage as the title suggests When the device reboots, there is a problem that starts from zero again.
Android 6.0 and later shows how to measure data usage using different APIs I can't use the terminal I'm testing because it's 4.4 version.
The problem is using the TrafficStats class.
I wonder if there is any other way.If you know how to do it, please answer.
Thank you.
android data usage traffic
TrafficStats
Related API documents seem to be intentionally designed to initialize to zero on reboot.
We recommend that you try NetworkStatsManager
for this.
Note that the statistics returned by this class reset and start from zero after every reboot. To access more robust historical network statistics data, use NetworkStatsManager instead.
© 2024 OneMinuteCode. All rights reserved.