0

I am trying to create a download progress bar while i am downloading files. I followed this tutorial however i can only make the progress bar count when i download files like images or mp3s.

What i need to be able to download are api responses such as these, but i cannot get their file size in order to have a reference for my progress bar.

        URL url = new URL(f_url[0]);
        URLConnection connection = url.openConnection();
        connection.connect();
        // this will be useful so that you can show a typical 0-100% progress bar
        int lenghtOfFile = connection.getContentLength();

When used on the API responses, the file size are -1 so the whole function is wrong.

What is a way to identify their sizes or any alternative way to create a progress bar while you download these.

Edit: I already am using Async task and it is working, the only problem is that i cannot increment my progress bar since i cannot get a file size.

linus
  • 481
  • 5
  • 18
  • you can use Async task..... – Piyush Aug 22 '13 at 12:28
  • @PiyushGupta: sorry forgot to mention, i am using async task already. I just need to know how to identify the file size of the file i am downloading or a way to increment the count for my progress dialog. – linus Aug 22 '13 at 12:29
  • you can refer this link..Useful to you.. http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog – Piyush Aug 22 '13 at 12:33

0 Answers0