jjzjj

TrafficStats

全部标签

android - 如何在 TrafficStats 中获取正确的发送和接收字节数?

我的应用正在尝试计算通过WiFi/LAN和移动数据连接发送和接收的字节数。为此,我在某个时间点获取了TrafficStats计数器的值,并在下次检查时从其值中减去该值。//getcurrentvaluesofcounterslongcurrentMobileTxBytes=TrafficStats.getMobileTxBytes();longcurrentMobileRxBytes=TrafficStats.getMobileRxBytes();longtotalTxBytes=TrafficStats.getTotalTxBytes();longtotalRxBytes=Traff
12