私がしたいのは、それぞれ3GトラフィックとWiFiトラフィックをカウントすることです。今私はWiFiをどうやって行うのか知っています。以下はWiFiのソースコードです。このようにして、私はすべての製造業者のすべてのアンドロイド携帯電話のWiFiトラフィックをカウントすることができます。しかし私は3gのために同様の方法を見つけていない。誰か知っていますか?アンドロイドモバイルで3gのトラフィックをカウントするには?
//to get wifi interface
private static String getProp(String prop){
String output = "";
try{
Class<?> sp = Class.forName("android.os.SystemProperites");
Method get = sp.getMethod("get",String.class);
output = (String)get.invoke(null,prop);
}catch(Exception e){
e.printStackTrace();
}
return output;
}
//to get the traffic from system file
...
...
if (connectinTpe == ConnectivityManager.TYPE_WIFI){
String wifiInterface = getProp("wifi.interface");
if(wifiInterface == null || "".equals(wifiInterface)) wifiInterface = "eth0";
rxFile = "/sys/class/net/" +wifiInterface+ "/statistics/rx_bytes";
txFile = "/sys/class/net/" +wifiInterface+ "/statistics/tx_bytes";
}
...
...
著者は現在の接続の種類を特定する方法ではなく、3Gトラフィックのカウント方法を尋ねました – Idolon