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.