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?
How to get Tethering and Mobile Hotspot data usage in Android using NetworkStatusManager or TrafficStat
1k views Asked by Sadjad Abbasnia At
2
There are 2 answers
0
On
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
You need to query by UID and pass in the tethering UID:
android.app.usage.NetworkStats.Bucket.UID_TETHERING
like so: