'How to get Tethering and Mobile Hotspot data usage in Android using NetworkStatusManager or TrafficStat

I have an Android application which displaying data usage per app by NetworkStatusManager, but I can't get data usage for Tethering and Mobile Hotspot. How should I do this?



Solution 1:[1]

What I did was to get the data from this files

/sys/class/net/< interface>/statistics/tx_bytes

/sys/class/net/< interface>/statistics/tr_bytes

then I saved the values using sharedpreference y made some code also for getting just the new values and add it to the saved values.

I made a lot of research but queryDetailsForUid using UID_TETHERING never worked

the interfaces are wlan and wwan

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Noe Adrian Acuña Prado