I use TrafficStats.getUidRxBytes to get network usage. It works fine for my app but for other apps always returns -1 (UNSUPPORTED). How can i get network usage for other apps without root permission?
How to monitor other apps network usage?
2.6k views Asked by amirreza sh At
1
Since android 7, you can query only your own app traffic usage. From
TraffixStats.getUidRxBytesdocs:Going to
NetworkStatsManager, you could usequeryDetailsForUid, but as documentation (https://developer.android.com/reference/android/app/usage/NetworkStatsManager.html) says:So be warned that the user must give some special permission to your app.
Edit:
I used once
UsageStatsManager, I think it's what you are looking for: https://developer.android.com/reference/android/app/usage/UsageStatsManager.html#queryUsageStats(int,%20long,%20long)