0

I'm really new on android, and Im trying to create a simple app that downloads a video file from the server...i was doing research and found that you can use downloadManager to this an it looks easy to use, but it looks that this option only accepts the url as a parameter and in order to download the video i have to send(post) some parameter to get access to the file, also I was reading that we can use async, but I'm not sure what is the best way to do it.

Thank you!

I was using this website as a reference; https://developer.android.com/reference/android/app/DownloadManager

Carlos Castro
  • 132
  • 1
  • 11
  • use Async for download video and api calling – Priyanka May 08 '19 at 06:31
  • You can check [this](https://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog) link and decide the best way suited to your use-case. – Jaydroid May 08 '19 at 07:05

1 Answers1

0

you can try this code

DownloadManager.Request request = new DownloadManager.Request(Uri.parse("your_video_url"));
                                request.setDescription("download");
                                request.setTitle("your_file_name");

                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                                    request.allowScanningByMediaScanner();
                                    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                                }
                                request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "your_file_name"+".mp4");
                                DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
                                manager.enqueue(request);
  • Thanks you, this is one of the options but I need to send(post) some parameter with the url in order to get access to download the file, it possible to add parameters using Downloadmanadger? – Carlos Castro May 08 '19 at 15:22