?
Dokumen ini menggunakan Manual laman web PHP Cina Lepaskan
TrafficStats
版本:Android 2.3 r1
結(jié)構(gòu)
繼承關(guān)系
public class TrafficStats extends Object
java.lang.Object
android.net.TrafficStats
類概述
提供網(wǎng)絡(luò)流量統(tǒng)計的類。這些統(tǒng)計包括通過所有網(wǎng)絡(luò)接口、mobile接口和UID網(wǎng)絡(luò)接口的字節(jié)發(fā)送和接收,網(wǎng)絡(luò)數(shù)據(jù)包的發(fā)送和接收。
這些統(tǒng)計可能不適用于所有平臺。如果本設(shè)備不支持統(tǒng)計,UNSUPPORTED將被返回。
常量
public static final int UNSUPPORTED
返回值表示該設(shè)備不支持統(tǒng)計。
常量值: -1 (0xffffffff)
公共方法
public static long getMobileRxBytes ()
獲取通過Mobile接口接收到的字節(jié)總數(shù)(Android123:這里不包含WiFi)
返回值
字節(jié)總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
public static long getMobileRxPackets ()
獲取通過Mobile接口接收到的數(shù)據(jù)包總數(shù)
返回值
數(shù)據(jù)包總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
public static long getMobileTxBytes ()
獲取通過Mobile接口發(fā)送的字節(jié)總數(shù)
返回值
字節(jié)總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
public static long getMobileTxPackets ()
獲取通過Mobile接口發(fā)送的數(shù)據(jù)包總數(shù)
返回值
數(shù)據(jù)包總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
public static long getTotalRxBytes ()
獲取通過所有網(wǎng)絡(luò)接口接收到的字節(jié)總數(shù)。(Android123:包含Mobile和WiFi等)
返回值
字節(jié)總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
public static long getTotalRxPackets ()
獲取通過所有網(wǎng)絡(luò)接口接收到的數(shù)據(jù)包總數(shù)。(Android123:包含Mobile和WiFi等)
返回值
數(shù)據(jù)包總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
public static long getTotalTxBytes ()
獲取通過所有網(wǎng)絡(luò)接口發(fā)送的字節(jié)總數(shù)。(Android123:包含Mobile和WiFi等)
返回值
字節(jié)總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
public static long getTotalTxPackets ()
獲取通過所有網(wǎng)絡(luò)接口發(fā)送的數(shù)據(jù)包總數(shù)(Android123:包含Mobile和WiFi等)
返回值
數(shù)據(jù)包總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
public static long getUidRxBytes (int uid)
獲取通過UID網(wǎng)絡(luò)接口收到的字節(jié)數(shù)。統(tǒng)計包含所有網(wǎng)絡(luò)接口。
參數(shù)
uid 待檢查的進程的uid
返回值
字節(jié)數(shù)
參見
myUid()
public static long getUidTxBytes (int uid)
獲取通過UID網(wǎng)絡(luò)接口發(fā)送的字節(jié)數(shù)。統(tǒng)計包含所有網(wǎng)絡(luò)接口。
參數(shù)
uid 待檢查的進程的uid
返回值
字節(jié)總數(shù)。如果本設(shè)備不支持統(tǒng)計,將返回
UNSUPPORTED。
參見
myUid()
補充
文章鏈接
Android流量統(tǒng)計TrafficStats類的使用