in Android Q, how to tracking an application's network statistics (rx and tx) . not getting rx and tx in android 10 using below code.Its working up to pie without any probs
while (!Thread.currentThread().isInterrupted()) {
// Parse the network traffic statistics pertaining to this connection
DataInputStream in = null;
try {
in = new DataInputStream(new FileInputStream("/proc/net/dev"));
final String prefix = "tun0" + ':';
while (true) {
String line = in.readLine().trim();
if (line.startsWith(prefix)) {
String[] numbers = line.substring(prefix.length()).split(" +");
boolean foundNonZero = false;
for (int i = 1; i < 17 && foundNonZero == false; ++i) {
if (!numbers[i].equals("0")) {
foundNonZero = true;
}
}
if (foundNonZero) {
rxBytes = numbers[NET_INTERFACE_BYTES_IN_COL];
txBytes = numbers[NET_INTERFACE_BYTES_OUT_COL];
}
break;
}
}
} catch (Exception e) {
// ignore
} finally {
try {
in.close();
} catch (Exception e) {
// ignore
}
}