Preface
This chapter is about android.net. TrafficStats and translated into "Traffic Statistics". The version is Android 2.3 r1. For more information, see "Android Development Network". Visit their Website: "http://android123.com.cn /". I look forward to your participation in Android API Chinese translation, contact me over140@gmail.com.
Statement
You are welcome to repost, but please keep the original source of the article :)
Android Network: http://android123.com.cn/
Blog Garden: http://www.cnblogs.com/
Android Chinese translation group: http://code.taobao.org/project/view/404/
Body
I. Structure
Public class TrafficStats extends Object
Java. lang. Object
Android.net. TrafficStats
Ii. Overview
Provides network traffic statistics. These statistics include byte sending and receiving through all network interfaces, mobile interfaces, and UID network interfaces, and sending and receiving network data packets.
These statistics may not apply to all platforms. If this device does not support statistics,UNSUPPORTED
Will be returned.
3. Constants
Public static final intUNSUPPORTED
The returned value indicates that the device does not support statistics.
Constant Value:-1 (0 xffffffff)
Iv. Public Methods
Public static longGetcyclerxbytes()
Obtain the total number of bytes received through the Mobile interface (Android123: WiFi is not included here)
Return Value
The total number of bytes. If this device does not support statistics,UNSUPPORTED will be returned.
Public static longGetMobileRxPackets()
Obtains the total number of packets received through the Mobile interface.
Return Value
Total number of data packets. If this device does not support statistics,UNSUPPORTED will be returned.
Public static longGetMobileTxBytes()
Obtains the total number of bytes sent through the Mobile interface.
Return Value
The total number of bytes. If this device does not support statistics,UNSUPPORTED will be returned.
Public static longGetMobileTxPackets()
Obtains the total number of data packets sent through the Mobile interface.
Return Value
Total number of data packets. If this device does not support statistics,UNSUPPORTED will be returned.
Public static longGetTotalRxBytes()
Obtains the total number of bytes received through all network interfaces. (Android123: including Mobile and WiFi)
Return Value
The total number of bytes. If this device does not support statistics,UNSUPPORTED will be returned.
Public static longGetTotalRxPackets()
Obtains the total number of packets received through all network interfaces. (Android123: including Mobile and WiFi)
Return Value
Total number of data packets. If this device does not support statistics,UNSUPPORTED will be returned.
Public static longGetTotalTxBytes()
Obtains the total number of bytes sent through all network interfaces. (Android123: including Mobile and WiFi)
Return Value
The total number of bytes. If this device does not support statistics,UNSUPPORTED will be returned.
Public static longGetTotalTxPackets()
Obtain the total number of data packets sent through all network interfaces (Android123: including Mobile and WiFi)
Return Value
Total number of data packets. If this device does not support statistics,UNSUPPORTED will be returned.
Public static longGetUidRxBytes(Int uid)
Obtains the number of bytes received through the UID network interface. Statistics include all network interfaces.
Parameters
Uid of the process to be checked
Return Value
Bytes
See
MyUid ()
Public static longGetUidTxBytes(Int uid)
Obtains the number of bytes sent through the UID network interface. Statistics include all network interfaces.
Parameters
Uid of the process to be checked
Return Value
The total number of bytes. If this device does not support statistics,UNSUPPORTED will be returned.
See
MyUid ()
5. Supplement
Article Link
Use of the TrafficStats class in Android traffic statistics