48300265 | Android Data traffic statistics-CSDN Blog
8440160 | How Android develops traffic monitoring software-CSDN Blog
Https://stackoverflow.com/questions/12613402/android-statistic-3g-traffic-for-each-app-how | Android statistic 3g traffic for each APP, how? -Stack Overflow
50513387 | "Smart router" device traffic, network speed statistics, and referral notifications (based on NetFilter programming)-CSDN Blog
78062778 | Android gets total mobile usage and statistics for an app's traffic-CSDN blog
71705835 | Android app traffic statistics--networkstatsmanager use-csdn Blog
Https://developer.android.google.cn/reference/android/net/TrafficStats | Trafficstats | Android Developers
52860071 | Trafficstats class for Android listening Speed-Csdn blog
52195001 | Android Traffic Optimization (i): Modular traffic statistics-CSDN Blog
https://developer.android.google.cn/| Android Developers
PR: According to the application statistics traffic consumption situation?
Listening to intercept network traffic
Trafficstats.
After--2.2 introduced a new Android.net.TrafficStats class can do network traffic statistics, can be statistical total traffic can also be counted the flow of a single process
The Android system keeps the release volume data in the file/proc/net/xt_qtaguid/stats (see source code)
Using the Trafficstats.setthreadtag (int tag) method to mark the thread that generated the traffic, the parameter tag is the tag associated with the above module; @See trafficstats;
Note:1, a thread will have a valid tag at the same time, and will not be passed, the dependent package initiates a new thread to access the network requires the relying party to provide token support; 2, native layer socket, WebView generated traffic can not use this method tag;
Trafficstats.getuidrxbytes (MYUID);
myUID is the UID of your application, which is obtained according to the program Activitymanager can get runing
It's probably getting the UID first, and then getting the incoming traffic based on that method.
Trafficstats.getuidtxbytes (myUID); This is the send traffic.
These are the beginning of the start of the meter, you want to count the month or something, write a way to save the overlay is
Static long Getmobilerxbytes ()//Gets the total number of bytes received via mobile connection, not including WiFi
Static long Getmobilerxpackets ()//Gets the total number of packets received by the mobile connection, not including WiFi
Static long Getmobiletxbytes ()//mobile The total number of bytes sent
Static long Getmobiletxpackets ()//mobile The total number of packets sent
Static long Gettotalrxbytes ()//Gets the total number of bytes accepted, including mobile and WiFi, etc.
Static long Gettotalrxpackets ()//Total number of accepted packets, including mobile and WiFi, etc.
Static long Gettotaltxbytes ()//The total number of bytes sent, packet
Android App Traffic stats