I've been developing a movie application that user can download movie via direct link. At end part I have problem. Does android have intent for downloading ? I want that when user click one button , one dialog showed and user can choose one of downloader(download applications), do they want ! Just like when we click on one direct link in browser.
Asked
Active
Viewed 2,068 times
0
-
See this question: https://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog?rq=1 – Xander Dec 11 '16 at 10:46
-
@Xander I see it this question is about create one custom download manger . I want one intent to choose downloder to download. – Sobhan Moradi Dec 11 '16 at 11:19
2 Answers
3
you can try this below
Uri uri = Uri.parse("http://apache.claz.org/nifi/1.1.0/nifi-1.1.0-bin.tar.gz");
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
this well show up a browsers list, you can choose one from them and the download will begin.

Yu Jiaao
- 4,444
- 5
- 44
- 57
-
I tried that . this way is good for downloading binary file as like .zip or .tar But in my case is movie format like .mkv or .mp4 – Sobhan Moradi Dec 11 '16 at 13:09
-
_Download_ or _play_ depends on your web server config, if you add `add_header Content-type Application/Octet-Stream; ` to your nginx server configuration, then the Browser will download but not to play it. try this url `Uri uri = Uri.parse("http://test.issll.com/demo/videoviewdemo.mp4"); ` – Yu Jiaao Dec 12 '16 at 07:44
-
Some devices don't work with this way. A tab of browser dissapear as soon as itshows up... – c-an Jan 15 '20 at 11:04
0
new Thread(new Runnable()
{
public void run()
{
File outputFile=new File("//sdcard//downloadCase.mp3");
try
{
if(!outputFile.exists())
{
outputFile.createNewFile();
}
else
{
outputFile.delete();
outputFile.createNewFile();
}
//CHANGE URL HERE
URL u = new URL("http://dl.blugaa.com/lq.blugaa.com/cdn7/3c0883064579a332dd7b627e3a904284/ylzuv/Mere%20Kol-(Mr-Jatt.com).mp3");
URLConnection conn = u.openConnection();
int contentLength = conn.getContentLength();
DataInputStream stream = new DataInputStream(u.openStream());
byte[] buffer = new byte[contentLength];
stream.readFully(buffer);
stream.close();
DataOutputStream fos = new DataOutputStream(new FileOutputStream(outputFile));
fos.write(buffer);
fos.flush();
fos.close();
}
catch(FileNotFoundException e)
{
return; // swallow a 404
}
catch (IOException e)
{
return; // swallow a 404
}
}
}).start();

Mike P
- 742
- 11
- 26

Reetpreet Brar
- 104
- 7