Really confused with bandwidth calculation formula.
Referring to the bandwidth detection question Check the bandwidth rate in Android i am trying to calculate bandwidth as following.
long startTime = System.currentTimeMillis();
HttpResponse response = httpclient.execute(httppost);
HttpEntity httpEntity = response.getEntity();
long contentLength = httpEntity.getContentLength();
long endTime = System.currentTimeMillis();
float bandwidth = contentLength / ((endTime-startTime) / 1000); // In the refereed question it is "((endTime-startTime) * 1000)" don't know why multiplication.
What i need is current bandwidth in bits (not bytes or kbytes). I don't know using above formula if it is calculating bandwidth in bytes or bits.
also if download time is 0 seconds then what should be the bandwidth is it downloaded content length. can someone please suggest correct formula to calculate bandwidth in bits.