/// <summary>
		/// Called when the activity is starting.
		/// </summary>
		/// <param name="savedInstanceState">If the activity is being re-initialized after
		/// previously being shut down then this Bundle contains the data it most
		/// recently supplied in <c><see cref="M:Android.App.Activity.OnSaveInstanceState(Android.OS.Bundle)" /></c>.  <format type="text/html"><b><i>Note: Otherwise it is null.</i></b></format></param>
		/// <since version="Added in API level 1" />
		/// <altmember cref="M:Android.App.Activity.OnStart" />
		/// <altmember cref="M:Android.App.Activity.OnSaveInstanceState(Android.OS.Bundle)" />
		/// <altmember cref="M:Android.App.Activity.OnRestoreInstanceState(Android.OS.Bundle)" />
		/// <altmember cref="M:Android.App.Activity.OnPostCreate(Android.OS.Bundle)" />
		/// <remarks><para tool="javadoc-to-mdoc">Called when the activity is starting.  This is where most initialization
		/// should go: calling <c><see cref="M:Android.App.Activity.SetContentView(System.Int32)" /></c> to inflate the
		/// activity's UI, using <c><see cref="M:Android.App.Activity.FindViewById(System.Int32)" /></c> to programmatically interact
		/// with widgets in the UI, calling
		/// <c><see cref="M:Android.App.Activity.ManagedQuery(Android.Net.Uri, System.String[], System.String[], System.String[], System.String[])" /></c> to retrieve
		/// cursors for data being displayed, etc.
		/// </para>
		/// <para tool="javadoc-to-mdoc">You can call <c><see cref="M:Android.App.Activity.Finish" /></c> from within this function, in
		/// which case onDestroy() will be immediately called without any of the rest
		/// of the activity lifecycle (<c><see cref="M:Android.App.Activity.OnStart" /></c>, <c><see cref="M:Android.App.Activity.OnResume" /></c>,
		/// <c><see cref="M:Android.App.Activity.OnPause" /></c>, etc) executing.
		/// </para>
		/// <para tool="javadoc-to-mdoc">
		///   <i>Derived classes must call through to the super class's
		/// implementation of this method.  If they do not, an exception will be
		/// thrown.</i>
		/// </para>
		/// <para tool="javadoc-to-mdoc">
		///   <format type="text/html">
		///     <a href="http://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)" target="_blank">[Android Documentation]</a>
		///   </format>
		/// </para></remarks>
		protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			var b = (savedInstanceState ?? Intent.Extras);

			var ran = b.GetBoolean("ran", false);

			_title = b.GetString(MediaStore.MediaColumns.Title);
			_description = b.GetString(MediaStore.Images.ImageColumns.Description);

			_tasked = b.GetBoolean(ExtraTasked);
			_id = b.GetInt(ExtraId, 0);
			_type = b.GetString(ExtraType);
			
			if (_type == "image/*")
			{
				_isPhoto = true;
			}

			_action = b.GetString(ExtraAction);
			Intent pickIntent = null;

			try
			{
				pickIntent = new Intent(_action);
				if (_action == Intent.ActionPick)
					pickIntent.SetType(_type);
				else
				{
					if (!_isPhoto)
					{
						_seconds = b.GetInt(MediaStore.ExtraDurationLimit, 0);
						if (_seconds != 0)
						{
							pickIntent.PutExtra(MediaStore.ExtraDurationLimit, _seconds);
						}
					}

					_quality = (VideoQuality) b.GetInt(MediaStore.ExtraVideoQuality, (int) VideoQuality.High);
					pickIntent.PutExtra(MediaStore.ExtraVideoQuality, GetVideoQuality(_quality));

					if (!ran)
					{
						_path = GetOutputMediaFile(this, b.GetString(ExtraPath), _title, _isPhoto);

						Touch();
						pickIntent.PutExtra(MediaStore.ExtraOutput, _path);
					}
					else
						_path = Uri.Parse(b.GetString(ExtraPath));
				}

				if (!ran)
				{
					if (global::Android.OS.Build.VERSION.Release == "6.0")
                                        {
		                            if (CheckSelfPermission(Manifest.Permission.Camera) != Android.Content.PM.Permission.Granted)
		                            {
		                                RequestPermissions(new string[] { Manifest.Permission.Camera }, 1);
		                            }
                                        }
					StartActivityForResult(pickIntent, _id);
				}
			}
			catch (Exception ex)
			{
				RaiseOnMediaPicked(new MediaPickedEventArgs(_id, ex));
			}
			finally
			{
				if (pickIntent != null)
					pickIntent.Dispose();
			}
		}
        /// <summary>
        /// Called when the activity is starting.
        /// </summary>
        /// <param name="savedInstanceState">If the activity is being re-initialized after
        /// previously being shut down then this Bundle contains the data it most
        /// recently supplied in <c><see cref="M:Android.App.Activity.OnSaveInstanceState(Android.OS.Bundle)" /></c>.  <format type="text/html"><b><i>Note: Otherwise it is null.</i></b></format></param>
        /// <since version="Added in API level 1" />
        /// <altmember cref="M:Android.App.Activity.OnStart" />
        /// <altmember cref="M:Android.App.Activity.OnSaveInstanceState(Android.OS.Bundle)" />
        /// <altmember cref="M:Android.App.Activity.OnRestoreInstanceState(Android.OS.Bundle)" />
        /// <altmember cref="M:Android.App.Activity.OnPostCreate(Android.OS.Bundle)" />
        /// <remarks><para tool="javadoc-to-mdoc">Called when the activity is starting.  This is where most initialization
        /// should go: calling <c><see cref="M:Android.App.Activity.SetContentView(System.Int32)" /></c> to inflate the
        /// activity's UI, using <c><see cref="M:Android.App.Activity.FindViewById(System.Int32)" /></c> to programmatically interact
        /// with widgets in the UI, calling
        /// <c><see cref="M:Android.App.Activity.ManagedQuery(Android.Net.Uri, System.String[], System.String[], System.String[], System.String[])" /></c> to retrieve
        /// cursors for data being displayed, etc.
        /// </para>
        /// <para tool="javadoc-to-mdoc">You can call <c><see cref="M:Android.App.Activity.Finish" /></c> from within this function, in
        /// which case onDestroy() will be immediately called without any of the rest
        /// of the activity lifecycle (<c><see cref="M:Android.App.Activity.OnStart" /></c>, <c><see cref="M:Android.App.Activity.OnResume" /></c>,
        /// <c><see cref="M:Android.App.Activity.OnPause" /></c>, etc) executing.
        /// </para>
        /// <para tool="javadoc-to-mdoc">
        ///   <i>Derived classes must call through to the super class's
        /// implementation of this method.  If they do not, an exception will be
        /// thrown.</i>
        /// </para>
        /// <para tool="javadoc-to-mdoc">
        ///   <format type="text/html">
        ///     <a href="http://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)" target="_blank">[Android Documentation]</a>
        ///   </format>
        /// </para></remarks>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var b = (savedInstanceState ?? Intent.Extras);

            var ran = b.GetBoolean("ran", false);

            _title = b.GetString(MediaStore.MediaColumns.Title);
            _description = b.GetString(MediaStore.Images.ImageColumns.Description);

            _tasked = b.GetBoolean(EXTRA_TASKED);
            _id = b.GetInt(EXTRA_ID, 0);
            _type = b.GetString(EXTRA_TYPE);

            if (_type == "image/*")
            {
                _isPhoto = true;
            }

            _action = b.GetString(EXTRA_ACTION);
            Intent pickIntent = null;

            try
            {
                pickIntent = new Intent(_action);
                if (_action == Intent.ActionPick)
                    pickIntent.SetType(_type);
                else
                {
                    if (!_isPhoto)
                    {
                        _seconds = b.GetInt(MediaStore.ExtraDurationLimit, 0);
                        if (_seconds != 0)
                        {
                            pickIntent.PutExtra(MediaStore.ExtraDurationLimit, _seconds);
                        }
                    }

                    _quality = (VideoQuality) b.GetInt(MediaStore.ExtraVideoQuality, (int) VideoQuality.High);
                    pickIntent.PutExtra(MediaStore.ExtraVideoQuality, GetVideoQuality(_quality));

                    if (!ran)
                    {
                        _path = GetOutputMediaFile(this, b.GetString(EXTRA_PATH), _title, _isPhoto);

                        Touch();
                        pickIntent.PutExtra(MediaStore.ExtraOutput, _path);
                    }
                    else
                        _path = Uri.Parse(b.GetString(EXTRA_PATH));
                }

                if (!ran)
                {
                    StartActivityForResult(pickIntent, _id);
                }
            }
            catch (Exception ex)
            {
                RaiseOnMediaPicked(new MediaPickedEventArgs(_id, ex));
            }
            finally
            {
                if (pickIntent != null)
                    pickIntent.Dispose();
            }
        }