I am using following code to get data used per application for a given time interval
long t1 = System.currentTimeMillis()-(60*1000);
long t2 = System.currentTimeMillis();
NetworkStats networkStats = networkStatsManager.querySummary(ConnectivityManager.TYPE_WIFI, null, t1, t2);
long data_tx = 0;
long data_rx = 0;
NetworkStats.Bucket bucket = new NetworkStats.Bucket();
while (networkStats.hasNextBucket()) {
networkStats.getNextBucket(bucket);
String callingApp = context.getPackageManager().getNameForUid(bucket.getUid());
data_tx = bucket.getTxBytes();
data_rx = bucket.getRxBytes();
}
but the values of bucket.getTxBytes() and bucket.getRxBytes() for any given application for given time interval is too big which can not be true as i have checked it with glasswire data monitoring app. So is this the right way to get data usage per application for any given time interval and also how can we have real time watch on application to monitor their internet activities?
Top comments (2)
Did you get the answer for this?
I'm dealing with same problem ..
Hi, I'm running into the same problem did eventually find a solution or reason why why