0
嗨,大家好我正在開發一款應用程序來顯示狀態欄上的數據速率。 數據傳輸速率
我的代碼是:
private class DataStatUtil implements Runnable {
private long startRX = 0;
private long lastRx = 0;
private Handler mHandler;
private Context context;
private Intent actionIntent;
public DataStatUtil(Context context ,Handler handler) {
this.context = context;
mHandler = handler;
startRX = TrafficStats.getTotalRxBytes();
}
@Override
public void run() {
long rxBytes = (TrafficStats.getTotalRxBytes()- startRX)/1024;
startRX = TrafficStats.getTotalRxBytes();
//my method to display on status bar
notifyOnStatusBar(rxBytes);
mHandler.postDelayed(this, 1000);
}
}
}
我問的是,這是正確的方式?
感謝您的重播。但我只關心接收率。 – 2014-12-04 07:01:18