Reputation: 43
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?
Upvotes: 1
Views: 1227
Reputation: 19
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
Upvotes: 0
Reputation: 46
You need to query by UID and pass in the tethering UID: android.app.usage.NetworkStats.Bucket.UID_TETHERING
like so:
networkStatsManager.queryDetailsForUid(ConnectivityManager.TYPE_MOBILE,
subscriberId, startDate, endDate,
android.app.usage.NetworkStats.Bucket.UID_TETHERING);
Upvotes: 3