1

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?

2 Answers2

3

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);
Jim L
  • 2,297
  • 17
  • 20
0

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