Find How Much Network Traffic Other Android Apps Generate
I am trying to make a background service which should measure traffic usage of various applications so as to be able to show to the user which apps consume most data traffic. I fou
Solution 1:
You can detect currently foreground application with ActivityManager.getRunningAppProcesses
call. It will return a list of RunningAppProcessInfo
records. To determine which application is on foreground check RunningAppProcessInfo.importance
field for equality to RunningAppProcessInfo.IMPORTANCE_FOREGROUND
.
But be ware that call to ActivityManager.getRunningAppProcesses()
method must be performed NOT in the UI thread. Just call it in the background thread (for example via AsyncTask) and it will return correct results. Check my post for additional details.
Post a Comment for "Find How Much Network Traffic Other Android Apps Generate"