Native GetManager() { if (this.downloadManager == null || this.downloadManager.Handle == IntPtr.Zero) { this.downloadManager = (Native)this.context.AppContext.GetSystemService(Context.DownloadService); } return(this.downloadManager); }
/// <summary> /// Use DownloadManager of Android to Download. User Can se status on Action Bar /// </summary> /// <param name="uri">Full url to download</param> /// <param name="filename">File to download</param> public void Download(string uri, string filename) { Android.Net.Uri contentUri = Android.Net.Uri.Parse(uri); Android.App.DownloadManager.Request r = new Android.App.DownloadManager.Request(contentUri); r.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, filename); r.AllowScanningByMediaScanner(); r.SetNotificationVisibility(Android.App.DownloadVisibility.VisibleNotifyCompleted); Android.App.DownloadManager dm = (Android.App.DownloadManager)Xamarin.Forms.Forms.Context.GetSystemService(Android.Content.Context.DownloadService); dm.Enqueue(r); }