When I open wifi and connected, TrafficStats.getMobileRxBytes() and TrafficStats.getMobileTxBytes() always return 0

When I open wifi and connected, TrafficStats.getMobileRxBytes() and TrafficStats.getMobileTxBytes() always return 0, but close wifi, get the value is right.

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

According to doc.

getMobileRxBytes return number of bytes received across mobile networks since device boot. Counts packets across all mobile network interfaces, and always increases monotonically since device boot.

And getMobileTxBytes return number of bytes transmitted across mobile networks since device boot. Counts packets across all mobile network interfaces, and always increases monotonically since device boot.

But it works according to doc only in Android 2 - 4. In Android 5 - 6 or even 7 it return zero when reconnect your mobile data.

There is an issue for the same.
https://issuetracker.google.com/issues/37009612