public void GetImageAsync(Action<MediaFile> imageData, bool fromCamera = true)
        {
            OnImageData = imageData;
            var context = Forms.Context as MainActivity;
            var picker = new MediaPicker(context);
            if (!picker.IsCameraAvailable)
                Console.WriteLine("No camera!");
            else
            {
                Intent intent = null;
                if (fromCamera)
                {
                    intent = picker.GetTakePhotoUI(new StoreCameraMediaOptions
                    {
                        Name = string.Format("vDoers_{0}.jpg", DateTime.Now.Ticks),
                        Directory = "vDoersCamera"
                    });
                }
                else
                {
                    intent = picker.GetPickPhotoUI();
                }

                context.OnActvitiResultCallback -= OnActvitiResultCallback;
                context.OnActvitiResultCallback += OnActvitiResultCallback;
                context.StartActivityForResult(intent, 1);
            }
        }
Exemple #2
0
        private void ButtonSendAttachmentEmail_Click(object sender, EventArgs eventArgs)
        {
            var picker = new MediaPicker(Application.Context);
            var intent = picker.GetPickPhotoUI();

            StartActivityForResult(intent, SelectPhoto);
        }
		public void TakePicture ()
		{
			var activity = Forms.Context as Activity;

			var picker = new MediaPicker(activity);

			var intent = picker.GetPickPhotoUI ();

			activity.StartActivityForResult(intent, 1);
		}
Exemple #4
0
 private void ChoosePhoto_Click(object sender, EventArgs e)
 {
     var picker = new MediaPicker(Activity);
     if (!picker.PhotosSupported)
     {
         ShowUnsupported();
         return;
     }
     var intent = picker.GetPickPhotoUI();
     StartActivityForResult(intent, 2);
 }
Exemple #5
0
        public async Task<Stream> PickPhoto()
        {
            var picker = new MediaPicker(Application.Context);
            var intent = picker.GetPickPhotoUI();

            intent.SetFlags(ActivityFlags.NewTask);

            Application.Context.StartActivity(intent);
           

            return null;
        }
    private void PickPhoto()
    {
      var picker = new MediaPicker(this);
      if (!picker.PhotosSupported)
      {
        Console.WriteLine("Photo's aren't supported");
        return;
      }
      

      var intent = picker.GetPickPhotoUI();

      StartActivityForResult(intent, 1);
    }
        public void GetImageAsync(Action<MediaFile> imageData, bool fromCamera = true)
        {
            var picker = new MediaPicker();
            MediaPickerController controller = null;
            if (fromCamera)
            {
                controller = picker.GetTakePhotoUI(new StoreCameraMediaOptions
                    {
                        Name = string.Format("vDoers_{0}.jpg", DateTime.Now.Ticks),
                        Directory = "vDoersCamera"
                    });
            }
            else
            {
                controller = picker.GetPickPhotoUI();
            }

            var window = UIApplication.SharedApplication.KeyWindow;
            var vc = window.RootViewController;
            if (vc != null)
            {
                // vc = vc.PresentedViewController;
                vc.PresentViewController(controller, true, null);
            }
            controller.GetResultAsync().ContinueWith(t =>
                {
                    // Dismiss the UI yourself
                    controller.DismissViewController(true, () =>
                        {
                            if (imageData != null)
                            {
                                imageData(t.Result);
                            }
                        });

                }, TaskScheduler.FromCurrentSynchronizationContext());
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.Main);
			
			Button videoButton = FindViewById<Button> (Resource.Id.takeVideoButton);
			videoButton.Click += delegate {
				// MediaPicker is the class used to invoke the
				// camera and gallery picker for selecting and
				// taking photos and videos
				var picker = new MediaPicker (this);

				// We can check to make sure the device has a camera
				// and supports dealing with video.
				if (!picker.IsCameraAvailable || !picker.VideosSupported) {
					ShowUnsupported();
					return;
				}
				
				// The GetTakeVideoUI method returns an Intent to start
				// the native camera app to record a video.
				Intent intent = picker.GetTakeVideoUI (new StoreVideoOptions {
					Name = "MyVideo",
					Directory = "MyVideos",
					DesiredLength = TimeSpan.FromSeconds (10)
				});

				StartActivityForResult (intent, 1);
			};
			
			Button photoButton = FindViewById<Button> (Resource.Id.takePhotoButton);
			photoButton.Click += delegate {
				var picker = new MediaPicker (this);

				if (!picker.IsCameraAvailable || !picker.PhotosSupported) {
					ShowUnsupported();
					return;
				}

				Intent intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions {
					Name = "test.jpg",
					Directory = "MediaPickerSample"
				});

				StartActivityForResult (intent, 2);
			};
			
			Button pickVideoButton = FindViewById<Button> (Resource.Id.pickVideoButton);
			pickVideoButton.Click += delegate {
				var picker = new MediaPicker (this);
				
				if (!picker.VideosSupported) {
					ShowUnsupported();
					return;
				}

				// The GetPickVideoUI() method returns an Intent to start
				// the native gallery app to select a video.
				Intent intent = picker.GetPickVideoUI();
				StartActivityForResult (intent, 1);
			};

			Button pickPhotoButton = FindViewById<Button> (Resource.Id.pickPhotoButton);
			pickPhotoButton.Click += delegate {
				var picker = new MediaPicker (this);

				if (!picker.PhotosSupported) {
					ShowUnsupported();
					return;
				}

				Intent intent = picker.GetPickPhotoUI(new StoreCameraMediaOptions {
					Name = "selected.jpg",
					Directory = "MediaPickerSample"
				});
				StartActivityForResult (intent, 2);
			};
		}
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView (Resource.Layout.Main);

			Button flickrButton = FindViewById<Button> (Resource.Id.Flickr);
			flickrButton.Click += (sender, args) =>
			{

				var picker = new MediaPicker (this);

				var intentPicker = picker.GetPickPhotoUI ();

				StartActivityForResult (intentPicker, 1);
			};

			Button facebookButton = FindViewById<Button>(Resource.Id.Facebook);
			facebookButton.Click += (sender, args) =>
			{
				try
				{
					Share (Facebook, facebookButton); 
				}
				catch (Exception ex)
				{
					ShowMessage("Facebook: " + ex.Message);
				}
			};
				
			Button twitterButton = FindViewById<Button> (Resource.Id.Twitter);
			twitterButton.Click += (sender, args) => 
			{
				try
				{
					Share (Twitter, twitterButton);
				}
				catch (Exception ex)
				{
					ShowMessage("Twitter: " + ex.Message);
				}
			};
				
		}
 public void SelectPhoto()
 {
     var picker = new MediaPicker(_context);
     var intent = picker.GetPickPhotoUI();
     _context.StartActivityForResult(intent, IntentConstants.SelectPhoto);
 }
        private void ChoosePhoto_Click(object sender, EventArgs e)
        {
            try
            {
                var picker = new MediaPicker(this);
                if (!picker.PhotosSupported)
                {
                    ShowUnsupported();
                    return;
                }

                var intent = picker.GetPickPhotoUI();
                this.StartActivityForResult(intent, 2);
            }
            catch (Exception exception)
            {
                GaService.TrackAppException(this.Class, "ChoosePhoto_Click", exception, false);
            }

        }