0

I'm trying to read out the traffic generated by the running applications. I pretty much want to get network usage data of every process.

TrafficStats.getUidRxBytes(ProcessUID); would sometimes return the right result, but sometimes a "-1" would be returned. If I understand correctly, TrafficStats.UNSUPPORTED is returned in the above cases, what I don´t understand is, why? I thought the UNSUPPORTED flag was meant to differ the ability of running device to fetch the data and was not bind in any way to a certain process.

        Integer ProcessUID = ProcessListData.get(i).getUID();
        Long RxBytes = TrafficStats.getUidRxBytes(ProcessUID);
        Long TxBytes = TrafficStats.getUidTxBytes(ProcessUID);

I am running Android 2.3.3. Thanks!

  • It seems a "-1" value is returned even if 0 RX/TX Bytes were received/sent through the respective app, not that big of a big deal actually. – Ermin Sakic Jun 01 '12 at 14:36

1 Answers1

0

"-1" means TrafficStats.UNSUPPORTED

See followin link, may be helpful for you

Can someone explain how TrafficStats works its magic in the Android OS?

Community
  • 1
  • 1
Chintan Raghwani
  • 3,370
  • 4
  • 22
  • 33