You can look at PhoneStateListener to determine the signal strength. Then just install chunkSize based on this.
I had to write an application in which I uploaded / uploaded large files (at the top 10-20 MB) using httppost. Downloading is easy because you can use the http "range" header. I could not figure out how to do this at boot.
The best way I could come up with is to open the RandomAccessFile file, read one piece from your file and write it to a temporary file, and then load this temp file. Scroll through the entire file, creating a temporary file for each fragment. Keep track of which chunkNum you are in preference. If that succeeds, you set chunkNum back to 0.
If the connection is not made in the middle of the download, the next time you try to download it, first check your chunkNum priority to see if it is greater than 0. RandomAccessFile seek () method to move the file pointer to the corresponding fragment and resume.
Unfortunately, this method adds delay to creating temporary files, but I could not come up with a better solution.
source share