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