开发者

Is it possible to enable TrafficStats on android emulator?

开发者 https://www.devze.com 2023-01-28 20:24 出处:网络
I\'m trying to get the total number transmitted bytes from the device (using getMobileTxBytes(). The number i\'m getting from the method call in the emulator is -1 (which means that this method not s

I'm trying to get the total number transmitted bytes from the device (using getMobileTxBytes().

The number i'm getting from the method call in the emulator is -1 (which means that this method not supported on the device). Is there any way to 开发者_开发技巧make the emulator return a reasonable number here? the best would be a number that will increase as i'm browsing the web in the emulator.


From the look at the stock Android source code (/frameworks/base/core/jni/android_net_TrafficStats.cpp), this class is pretty dumb, it has the network device names hard-coded inside, and it is looking at "rmnet0" and "ppp0" only, as mobile device names. So it is not going to detect network traffic in the emulator, unfortunately.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号