Measure data traffic on Android?

Just come back from a very pleasant vacation in Iceland and wait for the data transfer from my telephone company. I hope for the best by limiting my traffic as much as possible, but I want to know in advance. I used the very nice NetCounter application, but it didnโ€™t measure roaming data traffic at all.

So, I want to create my own application that measures only data traffic roaming. I have a few logical elements to start with ( NetworkInfo.IsRoaming () and TelephonyManager.isNetworkRoaming () ), but I'm not sure how to measure traffic if true .

So the question is: how to measure data traffic during roaming? (Something like TrafficStats level 8 API level is what I need, but for API level 3). Used smartphone - Samsung Galaxy i7500 (Android 1.6)

Thanx for your time!

+6
android traffic roaming
Aug 03 '10 at 7:44
source share
2 answers

Method 1. Parse "/ proc / net / dev".

On my phone, it looks like this:

 Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed lo: 712 8 0 0 0 0 0 0 712 8 0 0 0 0 0 0 dummy0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rmnet0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rmnet1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rmnet2: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 wlan0: 146112 423 32 0 0 0 0 0 42460 409 0 0 0 0 0 0 

On my phone, the line "rmnet0" is the one that stores statistics for the Internet network. I hope its format is independent of kernel versions.

Method 2: Analyze "/ sys / class / net".

I think this is the recommended method. As shown here: http://www.jaqpot.net/svn/android/netcounter/trunk/src/net/jaqpot/netcounter/service/SysClassNet.java

+9
Aug 10 '10 at 12:12
source share

There are several open source options in the comments:

I have currently installed 3G Watchdog. There are several comments by the author on AndroLib , which say that he doesnโ€™t want to release the source code, but with some help from the community, I โ€œOf course, we all could work together to make a better application for using the data there.

I think the best solution would be to take the code from NetMeter and start the service in the background. 3G Watchdog does this (a service called net.NetMonitorService ).

+3
Aug 09 '10 at 19:49
source share



All Articles