protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params) { Android.App.DownloadManager dm; uri = Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/Download/xyz.mp4")); string lastSegment = uri.PathSegments.Last(); string struri = uri.ToString(); if (System.IO.File.Exists(struri)) { // string currenturi = uri + lastSegment; return(null); } else { dm = Android.App.DownloadManager.FromContext(context); Android.App.DownloadManager.Request request = new Android.App.DownloadManager.Request(Android.Net.Uri.Parse(path)); request.SetTitle("Task App").SetDescription("Task video"); request.SetVisibleInDownloadsUi(true); request.SetNotificationVisibility(Android.App.DownloadVisibility.VisibleNotifyCompleted); request.SetDestinationUri(uri); var c = dm.Enqueue(request); } return(null); }
public async void Download_Click() { //var destination = Path.Combine( // System.Environment.GetFolderPath( // System.Environment.SpecialFolder.ApplicationData), // "music.mp3"); //await new WebClient().DownloadFileTaskAsync( // new System.Uri(path), // destination); Android.App.DownloadManager dm; uri = Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/Download/xyz.mp4")); string lastSegment = uri.PathSegments.Last(); string struri = uri.ToString(); if (System.IO.File.Exists(struri)) { // string currenturi = uri + lastSegment; return; } else { dm = Android.App.DownloadManager.FromContext(Activity); Android.App.DownloadManager.Request request = new Android.App.DownloadManager.Request(Android.Net.Uri.Parse(path)); request.SetTitle("Task App").SetDescription("Task Audio"); request.SetVisibleInDownloadsUi(true); request.SetNotificationVisibility(Android.App.DownloadVisibility.VisibleNotifyCompleted); request.SetDestinationUri(uri); var c = dm.Enqueue(request); } }
public void StartDownload(Android.App.DownloadManager downloadManager, string destinationPathName, bool allowedOverMetered, DownloadVisibility notificationVisibility, bool isVisibleInDownloadsUi) { using (var downloadUrl = Uri.Parse(Url)) using (var request = new Android.App.DownloadManager.Request(downloadUrl)) { if (Headers != null) { foreach (var header in Headers) { request.AddRequestHeader(header.Key, header.Value); } } if (destinationPathName != null) { var file = new Java.IO.File(destinationPathName); var uriPathFile = Android.Net.Uri.FromFile(file); request.SetDestinationUri(uriPathFile); //if (file.Exists()) //{ // file.Delete(); //} } request.SetVisibleInDownloadsUi(isVisibleInDownloadsUi); request.SetAllowedOverMetered(allowedOverMetered); request.SetNotificationVisibility(notificationVisibility); Id = downloadManager.Enqueue(request); } }
public void StartDownload(Android.App.DownloadManager downloadManager, string destinationPathName, bool allowedOverMetered) { using (var downloadUrl = Uri.Parse(Url)) using (var request = new Android.App.DownloadManager.Request(downloadUrl)) { if (Headers != null) { foreach (var header in Headers) { request.AddRequestHeader(header.Key, header.Value); } } if (destinationPathName != null) { request.SetDestinationUri(Uri.FromFile(new Java.IO.File(destinationPathName))); } request.SetAllowedOverMetered(allowedOverMetered); Id = downloadManager.Enqueue(request); } }
async void Download_Click() { Android.App.DownloadManager dm; uri = Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/Download/xyz.mp4")); string lastSegment = uri.PathSegments.Last(); string struri = uri.ToString(); if (System.IO.File.Exists(struri)) { // string currenturi = uri + lastSegment; return; } else { dm = Android.App.DownloadManager.FromContext(Activity); Android.App.DownloadManager.Request request = new Android.App.DownloadManager.Request(Android.Net.Uri.Parse(path)); request.SetTitle("Task App").SetDescription("Task Audio"); request.SetVisibleInDownloadsUi(true); request.SetNotificationVisibility(Android.App.DownloadVisibility.VisibleNotifyCompleted); request.SetDestinationUri(uri); var c = dm.Enqueue(request); } }