I am trying to use mobile data usage with TrafficStats.
Example:
mobileDataUsage = TrafficStats.getMobileRxBytes () + TrafficStats.getMobileTxBytes ()
totalUsage = TrafficStats.getTotalRxBytes () + TrafficStats.getTotalTxBytes ()
In several devices, it works absolutely fine. In Nexus 5X, I get totalUsage, but mobileDataUsage is always 0, TrafficStats.getMobileRxBytes() and TrafficStats.getMobileTxBytes() always returns 0.
source share