5

In android, i have this URL to which i must do a POST request the returned inputstream of said request returns a downloadable object... How can I use the Android Downloadmanager itself, or a custom created one, to handle the downloading process for me?

4
  • What is your target API? Commented Mar 3, 2013 at 14:10
  • minimum suported 2.3.6 development on a 4.1 tablet, but it's mainly intended for 2.3.6 Commented Mar 3, 2013 at 14:14
  • See if this stackoverflow.com/questions/2323617/… helps. Commented Mar 3, 2013 at 14:20
  • I had to write a seperate class to handle the download & progressbar manually, quite like the following ootooban.com/en/2012/… Commented Mar 3, 2013 at 15:21

2 Answers 2

1

http://ootooban.com/en/2012/custom-download-manager-for-android-2-1-part2-resumable-downloads/

Creating your own notification ontop of a post request, combined with a setProgress() & progressbar did the trick, so there is no conclusive way of using the DownloadManager sadly enough

Sign up to request clarification or add additional context in comments.

Comments

0

the android's Download manager is quite simple :

DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); Request request = new Request(Uri.parse("http://www.theeUrl.fake/image.png")); enqueue = dm.enqueue(request); 

you can easily add parameter as its a GET request. I don't know if you can make a POST request from it.

EDIT : to make a post request you can use an HttpClient like this :

HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); HttpResponse response = null; Dictionary<String, String> postFields = new Dictionary<String, String>(); // Set the post fields postFields.add("username","toto"))); postFields.add("password", "thePassword45155"))); post.setEntity(new UrlEncodedFormEntity(postFields, HTTP.UTF_8)); // Execute the POST request response = client.execute(post); 

you should be able to get an inputstream from the httpResponse to download the file. but you'll have to manage display / notification / cancellation... yourself.

8 Comments

that's exactly what I knew already, that's the point, i need a POST request, not a GET request
got that sry ;) I'm afraid you can't use the download manager then... i edit my post to add another solution
I already did all that stuff :( I found the solution, well, i basicly had to create my own notification & update it myself instead of automaticly
yep... why do it have to be a POST request ? you should probably manage authentification as a separate request, then once the session opened, use a session token in a get request to download the file ;)
i do that, but the server requires you to send along a parameter with an authenticated key before it'll serve you anything :)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.