user2011302
user2011302

Reputation: 391

Android Continuous Data Usage Monitoring

In our application we need to maintain logs for calls,sms and internet. In case of Internet we want to know the data usage of each application on daily, weekly or monthly basis.

We are able to figure out running applications' names through Activity Manager and RunningAppProcessInfo and we are able to detect number of bytes sent and received since the device boot using TrafficStats class but we need help to figure out How can we update these details continuously to provide daily or weekly information.

As the class TrafficStats will update the amount of data received and sent only when the device restarts.

Upvotes: 0

Views: 291

Answers (1)

anddev84
anddev84

Reputation: 1483

Please see a similar answer I posted here. You can use an alarm to go off just before midnight every day, and log the traffic stats along with the timestamps. That will also help you aggregate based on days/weeks/months.

The key will be to keep track of offsets, and know when to add or subtract based on device reboots.

Upvotes: 1

Related Questions