Пример #1
0
        private long DownloadInvoice(Context context, Android.Net.Uri uri, string fileName)
        {
            DownloadManager downloadManager = DownloadManager.FromContext(context);
            var             request         = new DownloadManager.Request(uri);

            request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
            request.SetDestinationInExternalFilesDir(context, Android.OS.Environment.DirectoryDownloads, fileName + ".pdf");
            return(downloadManager.Enqueue(request));
        }
 public void OnDownloadStart(string url, string userAgent, string contentDisposition, string mimetype, long contentLength)
 {
     DownloadManager.Request request = new DownloadManager.Request(Android.Net.Uri.Parse(url));
     request.AllowScanningByMediaScanner();
     request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
     request.SetDestinationInExternalFilesDir(Forms.Context, Android.OS.Environment.DirectoryDownloads, "mydeddp.pdf");
     DownloadManager dm = (DownloadManager)Android.App.Application.Context.GetSystemService(Android.App.Application.DownloadService);
     dm.Enqueue(request);
 }
        protected void Download(string title, string path, bool obsolete)
        {
            Console.WriteLine("Master Data Download URL: {0}", path);

            downloadManager = (DownloadManager)GetSystemService(DownloadService);
            CurrentRequest  = new DownloadManager.Request(Uri.Parse(path));
            CurrentRequest.SetTitle(title);
            CurrentRequest.SetDestinationInExternalFilesDir(this, "", CreateLocalFileName());
            downloadId = downloadManager.Enqueue(CurrentRequest);

            MonitorStatus();
        }
        public bool DownloadFile(string uri)
        {
            var manager       = (DownloadManager)Android.App.Application.Context.GetSystemService(Context.DownloadService);
            var documents     = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            var directoryname = Path.Combine(documents, "Workshops");
            var path          = Path.Combine(directoryname, "file.mp4");
            var req           = new DownloadManager.Request(Android.Net.Uri.Parse(uri));

            req.SetDestinationInExternalFilesDir(Android.App.Application.Context, null, path);
            var ret = manager.Enqueue(req);

            return(true);
        }
        /// <summary>
        /// Download an apk from a given url and name it with the given version number
        /// </summary>
        /// <param name="urlOfTarget">The url of the apk</param>
        /// <param name="targetVersion">The version number to append</param>
        public void Download(string urlOfTarget, string targetVersion)
        {
            var uri          = Android.Net.Uri.Parse(urlOfTarget);
            var request      = new DownloadManager.Request(uri);
            var downloadName = this.PackageName + "." + targetVersion + ".apk";

            request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
            request.SetAllowedOverMetered(true);
            request.SetTitle(string.Format("App update, Version: {0}", targetVersion));
            request.SetDestinationInExternalFilesDir(this.context, Android.OS.Environment.DirectoryDownloads, downloadName);
            request.SetMimeType("application/vnd.android.package-archive");

            this.downloadReference = this.downloadManager.Enqueue(request);
        }