Reputation: 355
I want to write a download service on android. However when I tried it, it downloads files as HTML not as .jpg for example. How do I fix it ?
Upvotes: 0
Views: 320
Reputation: 355
Nevermind I solved it. Just needed to add authorization key to my website as header. Thanks all.
Upvotes: 1
Reputation: 1268
Uri uri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(uri);
String filename = URLUtil.guessFileName(uri.getEncodedPath(), null, "image/jpeg");
request.setDescription(filename);
Upvotes: 0