Show Download progress inside activity using DownloadManager

You are dividing two integers:

final double dl_progress = (bytes_downloaded / bytes_total) * 100;

As bytes_downloaded is less than bytes_total, (bytes_downloaded / bytes_total) will be 0, and your progress will therefore always be 0.

Change your calculation to

final int dl_progress = (int) ((bytes_downloaded * 100l) / bytes_total);

to obtain the progress in whole (albeit floored) percentiles.

Leave a Comment