I have to an Activity in which I have to update the progress of the ProgressBar, with a value got from different class.
In download class I used this function to calculate progress..
public void publishDownloadProgress(long lengthoffile, long bytesDownloaded){
mFileLength = lengthoffile;
totalBytesDownloaded = bytesDownloaded;
mProgress = ((totalBytesDownloaded*100)/mFileLength);
}
and this to get progress
public long getDownloadProgress(){
return mProgress;
}
But when I use getDownloadProgress(); in my Activity, I only get 0 which is understandable since it only gets it one time.
But what I like instead is a series of continuous progress values using which I want to update my ProgressBar, how to do that?
You should call getDownloadProgress() multiple times.
and set some time between two call.
You are getting zero because first time progress may be zero.
wait for some time 4ex Thread.sleep(50000);
then again call getDownloadProgress() you will get updated value