Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从设备获取传输的字节总数(使用getMobileTxBytes()。
我从模拟器中的方法调用获得的数字是-1(这意味着设备不支持此方法)。有没有办法让模拟器在这里返回一个合理的数字?最好的数字会随着我在模拟器中浏览网页而增加。
从库存的 Android 源代码 (/frameworks/base/core/jni/android_net_TrafficStats.cpp) 来看,这个类非常愚蠢,它内部有硬编码的网络设备名称,它正在查看“rmnet0”和仅作为移动设备名称的“ppp0”。因此,不幸的是,它不会检测模拟器中的网络流量。