我已经搜索了很多关于这个。部分地找到解决目的的相同的代码。正如API文档所述,一旦设备重新启动,它就会重置计数器。有时,即使没有重新启动,计数器也会重置。以下是密码如何获取1个月的GPRS移动数据使用情况?
float totalRxBytes = (float)TrafficStats.getTotalRxBytes()/(float)1048576; // Received
float totalTxBytes = (float)TrafficStats.getTotalTxBytes()/(float)1048576; // Sent
float mobRxBytes = (float)TrafficStats.getMobileRxBytes()/(float)1048576;
float mobTxBytes = (float)TrafficStats.getMobileTxBytes()/(float)1048576;
float wifiRxBytes = totalRxBytes - mobRxBytes;
float wifiTxBytes = totalTxBytes - mobTxBytes;
但我想不出有什么办法让这些数据从特定的日期或一个月?请帮忙。任何指针将不胜感激。 谢谢。
请指点一下吗? – Bharat
你可能会在这里找到答案http://stackoverflow.com/a/7640565/6689101 – zombie