Can TrafficStats be included in Android emulator?

I am trying to get the total number of bytes transferred from a device (using getMobileTxBytes () .

The number that I get from calling the method in the emulator is -1 (this means that this method is not supported on the device). Is there any way to make the emulator return a reasonable number here? the best is a number that will increase as I browse the network in the emulator.

+4
source share
1 answer

From a look at the Android source code for Android (/frameworks/base/core/jni/android_net_TrafficStats.cpp), this class is pretty dumb, it has network device names hardcoded inside, and it only looks at "rmnet0" and "ppp0" , since the names of mobile devices, So, unfortunately, it will not detect network traffic in the emulator.

+7
source

All Articles