I am working on a project . I need to find out the download and upload speed per second ... So far i have find out the transmitted and received total bytes. Any help will be much appreciated. Here is my code..
mStartRX = TrafficStats.getTotalRxBytes();
mStartTX = TrafficStats.getTotalTxBytes();
if (mStartRX != TrafficStats.UNSUPPORTED
&& mStartTX != TrafficStats.UNSUPPORTED) {
mIsStatSupported = true;
}
long rxBytes = TrafficStats.getTotalRxBytes() - mStartRX;
txtRX.setText(Long.toString(rxBytes) + " bytes");
long txBytes = TrafficStats.getTotalTxBytes() - mStartTX;
txtTX.setText(Long.toString(txBytes) + " bytes");
int linkSpeed = mWifi.getConnectionInfo().getRssi();
txtWifi.setText(String.valueOf(linkSpeed) + " dBm");