TrafficStats functions always return -1
问题 When i try to retrieve traffic data using TrafficStats class, TrafficStats.getTotalRxBytes() and TrafficStats.getTotalTxBytes() functions always return -1 even if i use the browser to load some web pages. I knew from some forums that -1 mean that the device don't support the action. I used WVGA, NEXUS ONE and NEXUS S and the problem persists. Thank you. 回答1: If you are using emulator it might not work. Try on a real device. 来源: https://stackoverflow.com/questions/21330735/trafficstats