2

TrafficStats.getUidRxBytes(uid) gets the traffic of an app. But, I do not know which UID is the WiFi hotspot (which is a system app).

AID_WIFI's UID is 1010, so I have tried TrafficStats.getUidRxBytes(1010) when the WiFi hotspot is opened and another phone connect is connected to it (and searching retrieving some pictures from the Internet), but it just return -1.

If I run:

int uid = 1010;
long rx = TrafficStats.getUidRxBytes(uid);
sb.append("接受mobile:" + rx);
long tx = TrafficStats.getUidTxBytes(uid);
sb.append("发送mobile:" + rx);
long rx1 =  TrafficStats.getUidRxPackets(uid);
sb.append("接受wifi:" + rx1);
long tx1 = TrafficStats.getUidTxPackets(uid);
sb.append("发送wifi:" + tx1);
Log.e("test111",sb.toString());

The console log output is:

接受mobile:-1
发送mobile:-1
接受wifi:-1
发送wifi:-1
atxe
  • 5,029
  • 2
  • 36
  • 50
  • @Goot ,did you have solved your question? --I found TrafficStats.getTotalRxBytes but this won't let me monitor precisely the usage of the android mobile hotspot function –  internLee Oct 23 '15 at 08:28
  • grammar improved (keeping the meaning of the actual question), improved formatting – atxe Oct 24 '15 at 09:36

0 Answers0