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); } }