我试图找出在每个应用程序在Android中的数据使用量。像http://kschang.hubpages.com/hub/Data-Usage-Monitor-Apps-and-Widgets-for-Android-Phones-and-Devices#slide4646427
I am trying to find out the data usage in Android on a per-application basis. Something like http://kschang.hubpages.com/hub/Data-Usage-Monitor-Apps-and-Widgets-for-Android-Phones-and-Devices#slide4646427
我看了一下链接how去了解在Android ENV 检测数据使用
I looked at the link how to go about detecting data usage in the android env
但它没有多大帮助。
任何帮助将是非常美联社preciated。
Any help would be really appreciated.
编辑:
ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo( mInfo );
List<RunningAppProcessInfo> listOfRunningProcess = activityManager.getRunningAppProcesses();
Log.d(TAG,"XXSize: " + listOfRunningProcess.size());
for (RunningAppProcessInfo runningAppProcessInfo : listOfRunningProcess) {
if(runningAppProcessInfo.uid > 1026)
{
Log.d(TAG, "ANS " + runningAppProcessInfo.processName + " Id :" + runningAppProcessInfo.pid + " UID: " + runningAppProcessInfo.uid );
}
}
我尝试了上面的code为建议的阿科什直拉。然而,所有的UID是数字。不同于 app_79
如你上面提到的。这是好吗?
I tried the above code as suggested by Akos Cz. However all the UID are Numbers. Unlike app_79
as you have mentioned above. Is this alright?
以下链接可以帮助你找出如何编程detemrine每个应用程序的数据使用情况。
The following links should help you figure out how to programatically detemrine the data usage per application.
https://github.com/commonsguy/cw-andtuning/tree/master/TrafficMonitor
http://www.techrepublic.com/blog/app-builder/create-a-network-monitor-using-androids-trafficstats-class/774
http://agolovatyuk.blogspot.com/2012/04/android-traffic-statistics-inside.html
您将需要实现你的code使用 TraficStats API和跟踪送的字节数/每UID(应用程序)。接收
You will need to implement your code to use the TraficStats API and track the number of bytes sent/received per UID (application).