protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.MainLayout);

			// Create the picker instance
			picker = Picker.CreatePicker (OneDriveAppId);

			// Add the start picker listener
			FindViewById<Button> (Resource.Id.startPickerButton).Click += delegate {
				// Clear out any previous results
				ClearResultTable ();

				// Determine the link type that was selected
				LinkType linkType;
				if (FindViewById<RadioButton> (Resource.Id.radioWebViewLink).Checked) {
					linkType = LinkType.WebViewLink;
				} else if (FindViewById<RadioButton> (Resource.Id.radioDownloadLink).Checked) {
					linkType = LinkType.DownloadLink;
				} else {
					throw new Exception ("Invalid Radio Button Choosen.");
				}

				// Start the picker
				picker.StartPicking (this, linkType);
			};

			// Add the save as listener for download links
			FindViewById<Button> (Resource.Id.saveAsButton).Click += delegate {
				if (downloadUrl != null) {
					var downloadManager = DownloadManager.FromContext (this);
					var request = new DownloadManager.Request (downloadUrl);
					request.SetNotificationVisibility (DownloadVisibility.VisibleNotifyCompleted);
					downloadManager.Enqueue (request);
				}
			};
		}
 private void OnDownloadAvailable(YoutubeEntry feed, VideoInfo videoInfo, MediaType mediaType)
 {
     Controls.Title.Text = videoInfo.Title;
     Dm = (DownloadManager) Controls.Activity.BaseContext.GetSystemService(Context.DownloadService);
     var fileName = DownloadHelper.GetLegalPath(videoInfo.Title) + videoInfo.VideoExtension;
     var request =
         new DownloadManager.Request(Android.Net.Uri.Parse(videoInfo.DownloadUri.ToString()));
     request.SetAllowedNetworkTypes(DownloadNetwork.Wifi | DownloadNetwork.Mobile)
        .AddRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11")
        .SetShowRunningNotification(true)
        .SetAllowedOverRoaming(true)
        .SetTitle(videoInfo.Title)
        .SetDescription(fileName)
        .SetDestinationInExternalPublicDir(Android.OS.Environment.DirectoryDownloads, fileName);
     Enqueue = Dm.Enqueue(request);
 }
예제 #3
0
 private void OnFileDownload(object sender, DownloadEventArgs e)
 {
     var request = new DownloadManager.Request(Uri.Parse(e.Url));
     // TODO: this should be fixed on the server!
     request.AllowScanningByMediaScanner();
     request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
     // TODO: set proper file name
     request.SetDestinationInExternalPublicDir(Environment.DirectoryDownloads, "report.docx");
     var dm = this.Activity.GetSystemService(Context.DownloadService).JavaCast<DownloadManager>();
     dm.Enqueue(request);
     this.GoBack();
     Toast.MakeText(this.Activity, "Свалям файла...", ToastLength.Long).Show();
 }