コード例 #1
0
            //MyOrientationListener Listener { get; set; }

            protected override void OnCreate(Android.OS.Bundle savedInstanceState)
            {
                base.OnCreate(savedInstanceState);

                //Listener = new MyOrientationListener( this, Android.Hardware.SensorDelay.Normal );
                //Listener.Enable( );

                bool didStartCamera = false;

                if (savedInstanceState != null)
                {
                    // grab the last active element
                    didStartCamera = savedInstanceState.GetBoolean("DidStartCamera");
                    ImageFile      = savedInstanceState.GetString("ImageFile");
                }

                // make sure the camera hasn't already been started, which will happen if
                // the orientation of the device is changed while looking at the camera's preview
                // image.
                if (didStartCamera == false)
                {
                    // retrieve the desired location
                    Java.IO.File imageFile = (Java.IO.File) this.Intent.Extras.Get("ImageDest");

                    // create our intent and launch the camera
                    Intent intent = new Intent(MediaStore.ActionImageCapture);

                    // notify the intent where the captured image should go.
                    intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(imageFile));

                    // store it as an aboslute string
                    ImageFile = imageFile.AbsolutePath;

                    StartActivityForResult(intent, 0);
                }
            }