Researched Android traffic stats for a while
Send a summary of their own posts
1 Android has a trafficstats class that can be directly obtained
Total accepted Traffic trafficstats.gettotalrxbytes (),
Total send Traffic trafficstats.gettotaltxbytes ());
Mobile phone GPRS receiving amount trafficstats.getmobilerxbytes () not including WiFi;
Mobile phone GPRS sending amount trafficstats.getmobiletxbytes () not including WiFi;
The total receive volume of a process trafficstats.getuidrxbytes (Uid));
The total sending volume of a process trafficstats.getuidtxbytes (Uid));
These are statistics from one boot to one shutdown.
Therefore, to do a certain program of traffic statistics, be sure to pay attention to the switch machine, and this time after the boot is the first to start the program.
2 Android on top of the Trafficstats class
The data inside the first four read/proc/net/dev
The traffic in one of the subsequent processes is statistically/proc/uid_stat/*** data
Android Traffic statistics