Have you tried HttpEntity.getContentLength()
to help you predetermine the size of the file? If you use that in conjunction with something like AsyncTask's onProgressUpdate(), you should be able to implement that.
Take a look at this link
Download a file with Android, and showing the progress in a ProgressDialog
It has pretty much what you're looking for. it uses urlConnection to get the InputStream so you would need to adapt that to use HttpEntity. So maybe you'd have something like this.
@Override
protected String doInBackground(String... aurl) {
int count;
long contentLength = <yourHttpEntity>.getContentLength();
InputStream input = new BufferedInputStream(<yourHttpEntity>.getContent());
OutputStream output = new FileOutputStream("/sdcard/your_photo.jpg");
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress(""+(int)((total*100)/contentLength));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
}
and update your dialog in onProgressUpdate.