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);
				}
			};
		}
Ejemplo n.º 2
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();
 }