测量数据漫游流量在Android?测量、流量、数据、Android

2023-09-05 09:36:37 作者:蹲坟头吓唬鬼。

这是冰岛一个非常美妙的假期刚刚复出,并等待从我的电话公司漫游账单数据。我希望最好有限制了我的流量尽可能多的,但我想提前知道。我用了很不错的应用程序 NetCounter 但它并不能衡量漫游数据流量的。

Just back from a very nice vacation in Iceland, and await the data roaming bill from my phone company. I hope for the best having limited my traffic as much as possible, but I want to know in advance. I used the very nice app NetCounter but it didn't measure roaming data traffic at all.

所以我要建立自己的应用程序,尺寸仅为漫游数据流量。我有几个布尔下手(NetworkInfo.IsRoaming() &安培; TelephonyManager.isNetworkRoaming() ),但我不知道如何来衡量交通,如果

So I want to build my own app measuring just roaming data traffic. I have a few booleans to start with ( NetworkInfo.IsRoaming() & TelephonyManager.isNetworkRoaming() ), but I'm not sure how to measure the traffic if true.

所以,问题是:如何测量的数据流量,而漫游? (喜欢的东西API级别8 TrafficStats 的功能是什么,我以后,但对于API级别3)。所使用的智能手机三星Galaxy I7500(安卓1.6)的

So the question is: How do I measure data traffic while roaming? (Something like API level 8 TrafficStats functionality is what I'm after, but for API level 3). The used SmartPhone is Samsung Galaxy i7500 (Android 1.6)

感谢名单的时间!

推荐答案

在我的手机,它看起来像:

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

In my phone it looks like:

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

在我的手机了rmnet0行是一个包含了统计信息的移动路线互联网。我希望它的格式不内核版本不同而有所差异。

In my phone the "rmnet0" row is the one that holds the stats for mobile line internet. I hope its format does not vary among kernel versions.

我想这是推荐的方法。 如下所示:http://www.jaqpot.net/svn/android/netcounter/trunk/src/net/jaqpot/netcounter/service/SysClassNet.java

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