I am trying to fetch mobile data usage using TrafficStats.
Example:
mobileDataUsage = TrafficStats.getMobileRxBytes() +TrafficStats.getMobileTxBytes()
totalUsage = TrafficStats.getTotalRxBytes() + TrafficStats.getTotalTxBytes()
In few devices it is working absolutely fine. In Nexus 5X I am getting totalUsage but mobileDataUsage is always 0, TrafficStats.getMobileRxBytes()
and TrafficStats.getMobileTxBytes()
always return 0.