Пример #1
0
        public void Download(string uri)
        {
            string filename = "";
            var    validate = uri;

            if (uri.Contains("idpdf"))
            {
                var name = uri.Replace("http://www.sadm.gob.mx/Solicitudes/solicitudcfdi?idpdf=", "");
                filename = name.Replace("/", "") + ".pdf";
            }
            else
            {
                var name = uri.Replace("http://www.sadm.gob.mx/Solicitudes/solicitudcfdi?idxml=", "");
                filename = name.Replace("/", "") + ".xml";
            }
            Android.Net.Uri contentUri = Android.Net.Uri.Parse(uri);

            DownloadManager.Request r = new DownloadManager.Request(contentUri);


            r.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, filename);

            r.AllowScanningByMediaScanner();

            r.SetNotificationVisibility(Android.App.DownloadVisibility.VisibleNotifyCompleted);

            DownloadManager dm = (DownloadManager)Forms.Context.GetSystemService(Android.Content.Context.DownloadService);

            dm.Enqueue(r);
        }
Пример #2
0
        /// <summary>
        /// Starts download of given URL
        /// </summary>
        /// <param name="url">URL of file to download</param>
        /// <param name="filename">filename of file to download</param>
        private void StartDownload(string url, string filename)
        {
            var uri     = global::Android.Net.Uri.Parse(url);
            var request = new DownloadManager.Request(uri);

            request.SetTitle(filename);
            request.SetDescription("Downloading file...");

            var cookie = CookieManager.Instance.GetCookie(url);

            request.AddRequestHeader("Cookie", cookie);

            if (global::Android.OS.Build.VERSION.SdkInt < global::Android.OS.BuildVersionCodes.Q)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                request.AllowScanningByMediaScanner();
#pragma warning restore CS0618 // Type or member is obsolete
            }
            else
            {
                request.SetDestinationInExternalPublicDir(
                    global::Android.OS.Environment.DirectoryDownloads,
                    filename);
            }

            request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);

            var downloadManager = (DownloadManager)this.Context.GetSystemService(Context.DownloadService);
            downloadManager.Enqueue(request);

            Toast.MakeText(this.Context, "Image download started...", ToastLength.Short).Show();
        }
Пример #3
0
        // static Java.Lang.Thread downloadThread;
        public static void DownloadFromLink(string url, string title, string toast = "", string ending = "", bool openFile = false, string descripts = "")
        {
            try {
                print("DOWNLOADING: " + url);

                DownloadManager.Request request = new DownloadManager.Request(Android.Net.Uri.Parse(url));
                request.SetTitle(title);
                request.SetDescription(descripts);
                string mainPath = Android.OS.Environment.DirectoryDownloads;
                string subPath  = title + ending;
                string fullPath = mainPath + "/" + subPath;

                print("PATH: " + fullPath);

                request.SetDestinationInExternalPublicDir(mainPath, subPath);
                request.SetVisibleInDownloadsUi(true);
                request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);

                DownloadManager manager;
                manager = (DownloadManager)MainActivity.activity.GetSystemService(Context.DownloadService);

                long downloadId = manager.Enqueue(request);

                // AUTO OPENS FILE WHEN DONE DOWNLOADING
                if (openFile || toast != "")
                {
                    Java.Lang.Thread downloadThread = new Java.Lang.Thread(() => {
                        try {
                            bool exists = false;
                            while (!exists)
                            {
                                try {
                                    string p = manager.GetUriForDownloadedFile(downloadId).Path;
                                    exists   = true;
                                }
                                catch (System.Exception) {
                                    Java.Lang.Thread.Sleep(100);
                                }
                            }
                            Java.Lang.Thread.Sleep(1000);
                            if (toast != "")
                            {
                                App.ShowToast(toast);
                            }
                            if (openFile)
                            {
                                print("OPEN FILE");
                                string truePath = (Android.OS.Environment.ExternalStorageDirectory + "/" + fullPath);
                                OpenFile(truePath);
                            }
                        }
                        catch { }
                    });
                    downloadThread.Start();
                }
            }
            catch (Exception _ex) {
                error(_ex);
            }
        }
Пример #4
0
        private void Webview_Download(object sender, DownloadEventArgs e)
        {
            try
            {
                var source = Android.Net.Uri.Parse(e.Url);

                var request = new DownloadManager.Request(source);

                request.AllowScanningByMediaScanner();

                request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);

                request.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, source.LastPathSegment);

                var manager = (DownloadManager)this.GetSystemService(Context.DownloadService);

                manager.Enqueue(request);

                Toast.MakeText(this, "Downloading Indigent Reports", ToastLength.Short).Show();
            }

            catch (Exception ex)
            {
                Toast.MakeText(this, "Cannot Download the file", ToastLength.Short).Show();
                Console.WriteLine(ex.Message);
            };
        }
Пример #5
0
        public static long DownloadFile(string from, string to, DownloadManager dm)
        {
            //var uri = Android.Net.Uri.FromFile(new Java.IO.File(dir.AbsolutePath + to));
            var request = new DownloadManager.Request(Android.Net.Uri.Parse(from));

            request.SetDestinationInExternalPublicDir("Parlament/", to);
            return(dm.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(Android.App.DownloadVisibility.VisibleNotifyCompleted);
            request.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, "download");
            DownloadManager dm = (DownloadManager)Application.Context.GetSystemService(Context.DownloadService);

            dm.Enqueue(request);
        }
Пример #7
0
        private void Download(Link l)
        {
            var source  = Android.Net.Uri.Parse(l.Url);
            var request = new DownloadManager.Request(source);

            request.AllowScanningByMediaScanner();
            request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
            request.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, source.LastPathSegment);
            var manager = (DownloadManager)_Context.GetSystemService(Context.DownloadService);

            manager.Enqueue(request);
        }
Пример #8
0
        private void Download(string url, string dir)
        {
            var    downloadManager = (DownloadManager)context.GetSystemService(Context.DownloadService);
            string filename        = "pmi_download.pdf";

            context.RegisterReceiver(new Receiver(Path.Combine(dir, filename)), new IntentFilter(DownloadManager.ActionDownloadComplete));

            DownloadManager.Request request = new DownloadManager.Request(Android.Net.Uri.Parse(url));
            request.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, filename);
            request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted); // to notify when download is complete

            downloadManager.Enqueue(request);
        }
Пример #9
0
        public void DownloadAndInstallApp(string downloadurl)
        {
            var savefilename = downloadurl.Substring(downloadurl.LastIndexOf("/", StringComparison.Ordinal) + 1);

            //  var path = Path.Combine(savedir, savefilename);


            DownloadManager.Request request =
                new DownloadManager.Request(Android.Net.Uri.Parse(downloadurl));
            request.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, savefilename);
            // request.SetDestinationInExternalFilesDir(Application.Context, Android.OS.Environment.DirectoryDownloads, update. DownloadFileName);
            request.SetMimeType("application/vnd.android.package-archive");
            enqueeId = downloadManager.Enqueue(request);
        }
Пример #10
0
        public async Task DownloadAndInstall(DownloadManager manager)
        {
            string url     = @"https://app.cforce.live/com.payforce.apk";
            var    source  = Android.Net.Uri.Parse(url);
            var    request = new DownloadManager.Request(source);

            request.AllowScanningByMediaScanner();
            request.SetAllowedOverRoaming(true);
            request.SetDescription("Downloading PayForce");
            request.SetAllowedOverMetered(true);
            request.SetVisibleInDownloadsUi(true);
            string filename = URLUtil.GuessFileName(url, null, MimeTypeMap.GetFileExtensionFromUrl(url));

            MainActivity.FileName = filename;
            request.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, filename);
            request.SetNotificationVisibility(DownloadManager.Request.VisibilityVisibleNotifyCompleted);
            request.SetAllowedNetworkTypes(DownloadNetwork.Wifi | DownloadNetwork.Mobile);
            MainActivity.DownloadId = manager.Enqueue(request);
        }
Пример #11
0
        private async Task <long?> EnqueueDownload(string url, string fileName)
        {
            if (!await new PermissionRequester().RequestStorageWrite())
            {
                return(null);
            }

            var source  = Android.Net.Uri.Parse(url);
            var request = new DownloadManager.Request(source);

            request.AllowScanningByMediaScanner();
            request.SetAllowedOverRoaming(false);
            request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
            request.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, source.LastPathSegment);
            request.SetTitle(fileName);
            request.SetDescription(fileName);
            var manager = (DownloadManager)Application.Context.GetSystemService(Context.DownloadService);

            return(manager.Enqueue(request));
        }
Пример #12
0
        // for now it only downloads ifunny
        public bool TryDownloadFile(string input, out Exception ex)
        {
            ex = null;
            try
            {
                var parser = ParserFinder.FindParser(this.ctx, input, out var url);

                if (parser == null)
                {
                    Toast.MakeText(ctx, "Incompatible site.", ToastLength.Short).Show();
                    return(false);
                }

                parser.TryFetchVideoUrl(url, out string[] urls);

                foreach (var _url in urls)
                {
                    var    uri           = Android.Net.Uri.Parse(_url);
                    var    request       = new DownloadManager.Request(uri);
                    string fileExtension = MimeTypeMap.GetFileExtensionFromUrl(_url);
                    string filename      = $"download.{fileExtension}";

                    request.SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads,
                                                              $"DLBuddy/{parser.GetParserName()}/{filename}");

                    request.SetVisibleInDownloadsUi(true);
                    request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
                    request.SetTitle($"DLBuddy - {parser.GetParserName()}");
                    manager.Enqueue(request);
                }


                return(true);
            }
            catch (Exception e)
            {
                ex = e;
                return(false);
            }
        }
        public void descargar(string path, string archivo, string titulo, string link)
        {
            WebClient cliente2 = new WebClient();

            cliente2.DownloadFileAsync(new Uri("https://i.ytimg.com/vi/" + link.Split('=')[1] + "/mqdefault.jpg"), Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits/" + link.Split('=')[1]);
            //new
            if (titulo.Trim().Length > 45)
            {
                titulo = titulo.Remove(45);
            }
            tituloo = titulo;


            var manige = DownloadManager.FromContext(this);
            var requ   = new DownloadManager.Request(Android.Net.Uri.Parse(archivo));

            requ.SetDescription("Espere por favor");
            requ.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
            requ.SetTitle(tituloo);
            var destino = Android.Net.Uri.FromFile(new Java.IO.File(path));

            if (SettingsHelper.GetSetting("rutadescarga") == Android.OS.Environment.DirectoryDownloads)
            {
                requ.SetDestinationInExternalPublicDir(SettingsHelper.GetSetting("rutadescarga"), Path.GetFileName(path));
            }
            else
            {
                requ.SetDestinationUri(destino);
            }
            requ.AllowScanningByMediaScanner();

            requ.SetVisibleInDownloadsUi(true);



            manige.Enqueue(requ);

            if (Path.GetFileName(path).EndsWith(".mp3"))
            {
                ////////////////si es mp3
                string datosviejos = "";
                if (File.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d"))
                {
                    datosviejos = File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d");
                }
                else
                {
                    var asss = File.Create(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d");
                    asss.Close();
                }
                if (!Directory.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits"))
                {
                    Directory.CreateDirectory(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits");
                }

                if (!datosviejos.Contains(link.Split('=')[1]))
                {
                    var aafff = File.CreateText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d");
                    aafff.Write(datosviejos + Path.GetFileNameWithoutExtension(path) + "²" + link + "²" + path + "¤");
                    aafff.Close();
                }
                else
                {
                    var datosparsed   = PlaylistsHelper.GetMedia(Constants.CachePath + "/downloaded.gr3d");
                    var videoid       = link.Split('=')[1];
                    int indexelemento = datosparsed.FindIndex(ax => ax.Link.Contains(videoid));
                    datosparsed[indexelemento].Path = path;
                    var aafff = File.CreateText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d");
                    aafff.Write(PlaylistsHelper.SerializeMedia(datosparsed));
                    aafff.Close();
                }
            }
            //////////////////////////////////////////////si es mp4
            else
            {
                string datosviejos = "";
                if (File.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d2"))
                {
                    datosviejos = File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d2");
                }
                else
                {
                    var asss = File.Create(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d2");
                    asss.Close();
                }
                if (!Directory.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits"))
                {
                    Directory.CreateDirectory(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits");
                }

                if (!datosviejos.Contains(link.Split('=')[1]))
                {
                    var aafff = File.CreateText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d2");
                    aafff.Write(datosviejos + Path.GetFileNameWithoutExtension(path) + "²" + link + "²" + path + "¤");
                    aafff.Close();
                }
                else
                {
                    var datosparsed   = PlaylistsHelper.GetMedia(Constants.CachePath + "/downloaded.gr3d2");
                    var videoid       = link.Split('=')[1];
                    int indexelemento = datosparsed.FindIndex(ax => ax.Link.Contains(videoid));
                    datosparsed[indexelemento].Path = path;
                    var aafff = File.CreateText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d2");
                    aafff.Write(PlaylistsHelper.SerializeMedia(datosparsed));
                    aafff.Close();
                }
                MultiHelper.ExecuteGarbageCollection();
            }



            /*
             * Random brandom = new Random();
             * WebClient cliente2= new WebClient();
             * cliente2.DownloadFileAsync(new Uri("https://i.ytimg.com/vi/" + link.Split('=')[1] + "/mqdefault.jpg"), Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits/" + link.Split('=')[1]);
             * int randum = brandom.Next(2000, 50000) + brandom.Next(2000, 50000);
             * random = randum;
             * try {
             *  NotificationManager notificationManager =
             *   GetSystemService(Context.NotificationService) as NotificationManager;
             *  if (titulo.Trim().Length > 30)
             *  {
             *      titulo = titulo.Remove(30);
             *  }
             *  tituloo = titulo;
             *  var builder = new Notification.Builder(ApplicationContext);
             *  builder.SetContentTitle("Descargando " + titulo + "...");
             *  builder.SetContentText("Espere por favor");
             *
             *  builder.SetSmallIcon(Resource.Drawable.downloadbutton);
             *
             *
             *
             *  WebClient cliente = new WebClient();
             *
             * byte[] losbits = null;
             *  cliente.DownloadProgressChanged += (aasd, asddd) =>
             *  {
             *
             *      builder.SetContentTitle("Descargando "+titulo+"...");
             *      builder.SetContentText("Espere por favor");
             *      builder.SetSmallIcon(Resource.Drawable.downloadbutton);
             *      builder.SetProgress(100, asddd.ProgressPercentage, false);
             *      notificationManager.Notify(randum, builder.Build());
             *
             *  };
             * cliente.DownloadDataCompleted += (aa, aaa) =>
             * {
             *
             *  //  Intent intentss = new Intent(this,typeof(actividadacciones));
             *  //  intentss.PutExtra("prro", path);
             *  try {
             *  var selectedUri = Android.Net.Uri.Parse( prefs.GetString("rutadescarga",null)+ "/");
             *
             *  Intent intentssdd = new Intent(this,typeof(actividadadinfooffline));
             *  intentssdd.PutExtra("nombre", Path.GetFileName(path));
             *  intentssdd.PutExtra("link", link);
             *  intentssdd.PutExtra("path", path);
             *
             *
             *
             *
             *
             *  PendingIntent intentosd = PendingIntent.GetActivity(this, brandom.Next(2000, 50000) + brandom.Next(2000, 50000), intentssdd, PendingIntentFlags.UpdateCurrent);
             *
             *
             *  builder.SetContentTitle("Descarga completada de: "+titulo);
             *  builder.SetContentText("Toque para abrir");
             *  builder.SetSmallIcon(Resource.Drawable.downloadbutton);
             *  builder.SetContentIntent(intentosd);
             *      builder.SetOngoing(false);
             *      notificationManager.Notify(randum, builder.Build());
             *
             *  losbits = aaa.Result;
             *  var a = File.Create(path);
             *  a.Write(losbits, 0, losbits.Length);
             *  a.Close();
             *  string datosviejos = "";
             *  link = link.Replace('²', ' ');
             *  link= link.Replace('¤', ' ');
             *  path =path.Replace('²', ' ');
             *  path=path.Replace('¤', ' ');
             *
             *
             *  if (Path.GetFileName(path).EndsWith(".mp3")) {
             *  ///////////////////////////si es mp3
             *
             *  if (File.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d"))
             *  {
             *     datosviejos = File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d");
             *  }
             *  if (!Directory.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits"))
             *  {
             *      Directory.CreateDirectory(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits");
             *  }
             *
             *  if(!datosviejos.Contains(Path.GetFileNameWithoutExtension(path) + "²" + link + "²" + path + "¤"))
             *  {
             *      var aafff = File.CreateText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d");
             *      aafff.Write(datosviejos + Path.GetFileNameWithoutExtension(path) + "²" + link + "²" + path + "¤");
             *      aafff.Close();
             *
             *  }
             *
             *
             *  }
             *  //////////////////////////////////////////////si es mp4
             *  else
             *  {
             *      if (File.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d2"))
             *      {
             *          datosviejos = File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d2");
             *      }
             *      if (!Directory.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits"))
             *      {
             *          Directory.CreateDirectory(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits");
             *      }
             *
             *      if (!datosviejos.Contains(Path.GetFileNameWithoutExtension(path) + "²" + link + "²" + path + "¤"))
             *      {
             *          var aafff = File.CreateText(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/" + "downloaded.gr3d2");
             *          aafff.Write(datosviejos + Path.GetFileNameWithoutExtension(path) + "²" + link + "²" + path + "¤");
             *          aafff.Close();
             *
             *      }
             *          clasesettings.recogerbasura();
             *  }
             *      completada = true;
             *  }
             *  catch (Exception)
             *  {
             *      clasesettings.recogerbasura();
             *      Toast.MakeText(this, "ha ocurrido un error al descargar intente de nuevo", ToastLength.Long).Show();
             *     // StopForeground(false);
             *  }
             *
             * };
             *
             *  cliente.DownloadData(new Uri(archivo));
             * }
             * catch (Exception)
             * {
             *  NotificationManager notificationManager =
             *  GetSystemService(Context.NotificationService) as NotificationManager;
             *  var builder = new Notification.Builder(ApplicationContext);
             *  builder.SetContentTitle("ERROR AL DESCARGAR: " + titulo);
             *  builder.SetContentText("Intente de nuevo");
             *  builder.SetSmallIcon(Resource.Drawable.downloadbutton);
             *  builder.SetOngoing(false);
             *  notificationManager.Notify(randum, builder.Build());
             *  clasesettings.recogerbasura();
             *
             * }
             */
        }
Пример #14
0
        /// <summary>
        /// 开始下载
        /// </summary>
        public void Start(string apkUrl, string apkName)
        {
            var receiver = new DownLoadCompleteReceiver();

            // 注册广播接收器,当下载完成时自动安装
            _context.RegisterReceiver(receiver, new IntentFilter(DownloadManager.ActionDownloadComplete));

            if (DownloadMode != DownloadMode.Always)
            {
                var filePath = AEnvironment.GetExternalStoragePublicDirectory(DownloadDirectory).Path;
                file = new JFile(filePath, apkName);
                if (file.Exists())
                {
                    Console.WriteLine(file.Path);
                    if (DownloadMode == DownloadMode.Overwrite)
                    {
                        file.Delete();
                        //更新下载中的显示
                        //ContentValues values = new ContentValues ();
                        //values.Put ("deleted", 1);
                        //COLUMN_DELETED = "deleted";
                        //CONTENT_URI = Uri.parse("content://downloads/my_downloads");
                        //ALL_DOWNLOADS_CONTENT_URI = Uri.parse("content://downloads/all_downloads")
                        //_context.ContentResolver.Update (ContentUris.WithAppendedId (AUri.Parse ("content://downloads/my_downloads"), _downloadID), values, null, null);
                        _context.ContentResolver.Delete(AUri.Parse("content://downloads/my_downloads"), "_data=?", new string[] { file.Path });
                    }
                    else
                    {
                        //发送广播
                        var intent = new Intent();
                        intent.SetAction(DownloadManager.ActionDownloadComplete);
                        _context.SendBroadcast(intent);
                        return;
                    }
                }
            }

            //判断是否有正在下载的相同任务
            DownloadManager.Query downloadQuery = new DownloadManager.Query();
            //根据下载状态查询下载任务
            downloadQuery.SetFilterByStatus(DownloadStatus.Running);
            //根据任务编号查询下载任务信息
            //downloadQuery.setFilterById(id);
            var cursor = downloadManager.InvokeQuery(downloadQuery);

            if (cursor != null)
            {
                if (cursor.MoveToNext())
                {
                    if (apkUrl.Equals(cursor.GetString(cursor.GetColumnIndex(DownloadManager.ColumnUri))))
                    {
                        Toast.MakeText(_context, "已存在的下载任务", ToastLength.Short).Show();
                        cursor.Close();
                        return;
                    }
                }
                cursor.Close();
            }

            downLoadRequest = new DownloadManager.Request(AUri.Parse(apkUrl));
            downLoadRequest.SetTitle(Title);
            downLoadRequest.SetDescription(Description);
            downLoadRequest.AllowScanningByMediaScanner();
            downLoadRequest.SetVisibleInDownloadsUi(true);
            //设置在什么网络情况下进行下载
            downLoadRequest.SetAllowedNetworkTypes(AllowedNetworkType);
            //设置通知栏标题
            downLoadRequest.SetNotificationVisibility(DownloadVisibility.Visible | DownloadVisibility.VisibleNotifyCompleted);
            //设置下载文件的mineType
            downLoadRequest.SetMimeType("application/com.trinea.download.file");
            //downLoadRequest.SetDestinationInExternalFilesDir
            //设置保存位置
            downLoadRequest.SetDestinationInExternalPublicDir(DownloadDirectory, apkName);
            //保存任务ID
            _downloadID = downloadManager.Enqueue(downLoadRequest);
        }