Network traffic monitoring per android application
I was wondering if I can do network traffic monitoring开发者_开发技巧 per android application?
Basically see which app is receiving/sending how much data?
I know there are many apps which already do that but I want to know how to do it.
Well you surely can. A very simple way is to use the TrafficStats class. It can manage per app (more formally, per UID) But the problem is, it can return UNSUPPORTED
. When this happens, I don't think you will have some easy (i.e. using the high level Java language) method to get the network traffic data you need.
Not sure if it can be implemented in Java as I imagine you need to access some low-level Operating system functions which are just not available in Java (but don't quote me on this!).
The obvious way I see of doing this is through C language and the Android Native Development Kit.
精彩评论