我正在尝试按特定 SIM 插槽查找数据使用情况。为此,我使用了 TrafficStats.getMobileRxBytes() 方法,但它提供了双 SIM 卡设备中两个 SIM 卡的总使用量。
下面是我返回总使用量的代码:
long rxBytes = (TrafficStats.getTotalRxBytes()- mStartRX)/ 1048576;
RX.setText(Long.toString(rxBytes));
long txBytes = (TrafficStats.getTotalTxBytes()- mStartTX)/ 1048576;
TX.setText(Long.toString(txBytes));
Log.d("totalWifiRe", (TrafficStats.getTotalRxBytes() - TrafficStats.getMobileRxBytes())/ 1048576+" MB");
Log.d("totalWifiTx", (TrafficStats.getTotalTxBytes()- TrafficStats.getMobileTxBytes())/ 1048576+" MB");
Log.d("totalDataRe", (TrafficStats.getMobileRxBytes()/ 1048576)+" MB");
Log.d("totalDataTx", (TrafficStats.getMobileTxBytes()/ 1048576)+" MB");
Log.d("SIM_STATUS", TrafficStats.getThreadStatsTag()+"");
Log.d("DailyNetUsage", "");
Log.d("CurrentTx", txBytes+" MB");
Log.d("CurrentRx", rxBytes+" MB");
我想要个人 SIM 的特定数据使用情况。任何建议将不胜感激。
一些应用程序正在这样做,例如 smartapp。