Created
December 19, 2017 12:18
-
-
Save arthtilva/e1740577408543a5920d1854ff0f01c1 to your computer and use it in GitHub Desktop.
data usage of app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActivityManager manager = (ActivityManager) activity.getSystemService(activity.ACTIVITY_SERVICE); | |
List<ActivityManager.RunningAppProcessInfo> runningApps = manager.getRunningAppProcesses(); | |
Log.i("TAG", "onCreate: " + runningApps.size()); | |
for (ActivityManager.RunningAppProcessInfo runningApp : runningApps) { | |
// Get UID of the selected process | |
int uid = runningApp.uid; | |
// Get traffic data | |
long received = TrafficStats.getUidRxBytes(uid); | |
long send = TrafficStats.getUidTxBytes(uid); | |
Log.v("bytes" + uid, "Send :" + send + ", Received :" + received); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment