Questions tagged [networkstatsmanager]
32 questions
17
votes
2 answers
Getting mobile data usage history using NetworkStatsManager
I want to know the data usage history and noticed the "new" android-6 NetworkStatsManager which seems positive (I've used TrafficStats a while but that won't cover anything previous a reboot).
From the API documentation:
NOTE: This API requires…

dacwe
- 43,066
- 12
- 116
- 140
9
votes
1 answer
NetworkStatsManager.queryDetailsForUid not obtaining the "same" values as TrafficStats
I'm comparing the new NetworkStats class with TrafficStats for measuring traffic for the network interfaces and a given application (pex Chrome)
Since TrafficStats has values since device boot the test that I'm performing is this:
Reboot phone.…

Favolas
- 6,963
- 29
- 75
- 127
6
votes
0 answers
PACKAGE_USAGE_STATS permission issue when pushed apk as system app
I'd implemented an app to get data usage, for getting data we need to give two permissions -
PACKAGE_USAGE_STATS
READ_PHONE_STATE
When I install app as play store app it works fine but when I push it as system app it crashes. Reason for this…

Gaurav Sharma
- 65
- 4
5
votes
3 answers
Get mobile data usage in Android 10
I'm trying to make a network usage monitor app, which shows mobile data usage history to the user. For this I'm using Usage access to get accurate data usage stats from NetworkStatsManager. But this no longer works in Android 10.
I'm using…

nisargjhaveri
- 1,469
- 11
- 21
5
votes
1 answer
Android data counter discrepancy (sum of apps < total)
I am trying to understand the cause of a data discrepancy I'm noting with only a couple of applications. In both Tidal and Apple music, if I skip through tracks while listening to them, I will immediately get a 10% to 15% data discrepancy between…

C Vanstone
- 89
- 4
4
votes
0 answers
NetworkStatsManager: querySummary returns the same data for different start time
I'm trying to use NetworkStatsManager class to retrieve the data usage of my app. I want to track it once in an hour (intervals of an hour) and as I read queryDetails is not an option for me because it's just for 2-3 hours.
when I tried to use…

Gal
- 63
- 1
- 10
4
votes
3 answers
Android mobile usage history NetworkStatsManager
I'm making an App for Android 6.0 and I want to use the new class NetworkStatsManager for getting mobile data usage.
I added all permission I need in manifest and require the permission runtime.
When I call the method:
bucket =…

Allen Walker
- 866
- 1
- 9
- 17
3
votes
0 answers
Android - reset NetworkStatsManager Received and Transmitted bytes to Zero
Is there a way to reset the Received and Transmitted bytes for all apps using NetworkStatsManager ?
I am using the below code to get the Network usage of the apps installed on the device.
private void getNetworkStatsBuckets(PackageManager pm)…

Nayra Ahmed
- 657
- 1
- 9
- 29
3
votes
0 answers
NetworkStatsManager's queries take too long
I'm trying to get statistics of traffic used on last 30days on each application using NetworkStatsManager , so i wrote a code as following :
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
NetworkStatsManager…

Mehrdad
- 180
- 1
- 13
3
votes
1 answer
NetworkStatsManager.queryDetailsForUid is not getting proper data for given time Interval
1) I am checking on Nougat, I already have following permission
2)…

PAVAN
- 771
- 4
- 14
3
votes
1 answer
NetworkStatsManager's queryDetailsForUid() method always returns old network usage for all the apps
I have written a code to get network usage but queryDetailsForUid(int networkType, String subscriberId,long startTime, long endTime, int uid) this method always returns old data.
How can I get updated data…

Kunal
- 55
- 1
- 9
2
votes
0 answers
Android device and app-wise data usage tracking using NetworkstatsManager return incorrect data
I'm trying to monitor device and app-wise data usage at every 15min interval of time.
I found that Android OS aggregating data usage every 2hr (Not mentioned in developer doc).
Found aggregation time logic using method queryDetailsForUid(). Does any…

Akshay Kumar S
- 333
- 3
- 12
2
votes
1 answer
Is it possible to query data of network usage before the installation date of the app
I'm writing a part of an app that displays mobile data usage and I also want it to display data from before the user installed the app. Currently, whenever I query data for a time range before the app was installed on a certain device,…

jurrdb
- 301
- 3
- 13
2
votes
0 answers
Is it possible to monitor the data usage for an specific WIFI network in Android?
I want to monitor the data usage for an specific WIFI network using an Android device. Looking into the API's documentation, I've found the following classes NetworkStatsManager and UsageStatsManager, but none of them seems to help me. Is it…

Hanna D
- 29
- 2
2
votes
2 answers
Android NetworkStats.Bucket data not updating
I am building an application which monitors applications network data usage over some interval.
On android 5 I had no problem with TrafficStats, although on android 8 using NetworkStats I always receive same data. I've read that bucket refreshes…

Gomez
- 81
- 1
- 5