A
Android Central Question
Dear Support,
I have an android app which is downloading the PDF from server,I am using
DownloadIntentService class for downloading, here I am using
sometime its downloading very fast while sometime very slow, I have checked the internet connection also , its fine, while download spped is fine but app is taking time to download
what could be the issue,
con = (HttpURLConnection) url.openConnection();
is = con.getInputStream();
fos = new FileOutputStream(path);
int lenghtOfFile = con.getContentLength();
byte data[] = new byte[51200];
Bundle b = new Bundle();
int upd;
long total=0;
while ((count = is.read(data)) != -1) {
total+=count;
// write data to file
fos.write(data, 0, count);
// send progress to MainActiivty through ResultReceiver
b.putString("progress", (int)((total*100)/lenghtOfFile)+"");
upd=(int)((total*100)/lenghtOfFile);
// Log.d("downloaded %: ", "" + (int)((total*100)/lenghtOfFile)+"");
// resultReceiver.send(CustomAdapterHome.RESULT_CODE, b);
I have an android app which is downloading the PDF from server,I am using
DownloadIntentService class for downloading, here I am using
sometime its downloading very fast while sometime very slow, I have checked the internet connection also , its fine, while download spped is fine but app is taking time to download
what could be the issue,
con = (HttpURLConnection) url.openConnection();
is = con.getInputStream();
fos = new FileOutputStream(path);
int lenghtOfFile = con.getContentLength();
byte data[] = new byte[51200];
Bundle b = new Bundle();
int upd;
long total=0;
while ((count = is.read(data)) != -1) {
total+=count;
// write data to file
fos.write(data, 0, count);
// send progress to MainActiivty through ResultReceiver
b.putString("progress", (int)((total*100)/lenghtOfFile)+"");
upd=(int)((total*100)/lenghtOfFile);
// Log.d("downloaded %: ", "" + (int)((total*100)/lenghtOfFile)+"");
// resultReceiver.send(CustomAdapterHome.RESULT_CODE, b);