开发者

Any way to figure out bytes sent/recvd over a data connection on Android? [duplicate]

开发者 https://www.devze.com 2023-04-12 03:01 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: android: how do i measure the traffic my smartphone produces?
This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

android: how do i measure the traffic my smartphone produces?

I was just wondering if android logs the bytes sent/recvd over a data connection somewhere. I was trying to play around with logcat, but could'nt get anything much (Im sure Ive missing something considering this is the first time im playing around with it).

Also I understand logcat is a circular log, so does that mean old logs simply get purged or is it backed-up somewhere ? I was hoping to get usage statistics of my data connectivity over the past wee开发者_JAVA百科k or so.

Thanks in advance


I was just wondering if android logs the bytes sent/recvd over a data connection somewhere.

As pointed out in the comment, the answer is to use TrafficStats.

I was trying to play around with logcat, but could'nt get anything much (Im sure Ive missing something considering this is the first time im playing around with it).

Data transfers are not recorded in LogCat.

Also I understand logcat is a circular log, so does that mean old logs simply get purged or is it backed-up somewhere ?

By definition, a ring buffer like LogCat uses purges old records to make room for new ones.

I was hoping to get usage statistics of my data connectivity over the past week or so.

Record it yourself within your application via TrafficStats. Or create a separate application that runs and records the data via TrafficStats, such as this sample app.

Also, the API requires the process UID.

Not all the methods on TrafficStats require a UID.

do u have a solution that tracks total bytes across a network connection and a give time slice ?

Use getTotalRxBytes() and getTotalTxBytes().

0

精彩评论

暂无评论...
验证码 换一张
取 消