I'm trying to measure data usage on Android, but... Rebooting will initialize the data.

Asked 2 years ago, Updated 2 years ago, 66 views

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

2022-09-22 12:35

1 Answers

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.


2022-09-22 12:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.