0

I'm not asking about implementation of TrafficStats in my app. I just wanna know how it works in the background. Is it monitoring the wifi clip or something to get the network traffic or just transmitting/downloading own bytes in every specific time to know the current network speed?

Thank you :)

Min Naing Oo
  • 1,085
  • 5
  • 24
  • 49

1 Answers1

1

"...just transmitting/downloading own bytes in every specific time to know the current network speed?", You don't get the network speed, you get the bytes sent/received. They are one of total/mobile/uid bytes. RTFM.

As for how it is done, in short, the (linux) kernel writes them in a special (proc) filesystem. They are available as readable files. The android framework reads it from those files. Here's a similar SO question: and the source code for TrafficStats.

Community
  • 1
  • 1
iceman
  • 826
  • 13
  • 25