My android app would have a link on it to a server that is hosting a file. I would like my app to download this file from the server in the background, so that the user can keep the app in focus and continue doing what he wants to do.
I assume that AsyncTask can be used to do this in background. The link in the app is to a php page, which has the following code -
header("Content-type: application/xls");
header("Content-Disposition: attachment; filename=\myFile.xls\"");
readfile("myFile.xls");
From what I understand, the readfile() will get data from the server, and then write it into its buffer. And the AsyncTask would read from this buffer and store it into the location in the phone as specified.
My question - 1. Do let me know if my approach is correct (what I have described above) 2. I assume that the header("Content-Disposition: ..) will result in a OPEN/SAVE Dialog box (as in the case of normal desktop browser dialog box). Will similar dialog box be displayed when the link is called by an android app as well? If yes, is there someway to not show this dialog box and instead just download, so that the user need not bother where the file is getting stored in his phone?
Thanks!