title: Xamarin set camera resolution
body: <p>I have done a custom camera application in Xamarin Visual Studio, it takes the pictures with a very low resolution, so I added this piece of code.</p>
  
  <pre><code>public void OnSurfaceTextureAvailable(Android.Graphics.SurfaceTexture surface, int w, int h)
          {
              _camera = Android.Hardware.Camera.Open();
              Android.Hardware.Camera.Parameters param = _camera.GetParameters();
              IList&lt;Android.Hardware.Camera.Size&gt; supportedSizes = param.SupportedPictureSizes;
              Android.Hardware.Camera.Size sizePicture = supportedSizes[0];
              param.SetPictureSize(sizePicture.Height, sizePicture.Width);
              _camera.SetParameters(param);
  
              var previewSize = _camera.GetParameters().PreviewSize;
              _textureView.LayoutParameters = 
                  new FrameLayout.LayoutParams(h, w, GravityFlags.Center);
              try
              {
                  _camera.SetPreviewTexture(surface);
                  _camera.StartPreview();
              }
              catch (Java.IO.IOException ex)
              {
                  Console.WriteLine(ex.Message);
              }
              _textureView.Rotation = 90.0f;
          }
  </code></pre>
  
  <p>In the firts line I get the Camera Parameters, then  I get the Supported Picture Size after that I select the firts ([0])  and finallly I set the Picture Size, </p>
  
  <pre><code>Android.Hardware.Camera.Parameters param = _camera.GetParameters();
              IList&lt;Android.Hardware.Camera.Size&gt; supportedSizes = param.SupportedPictureSizes;
              Android.Hardware.Camera.Size sizePicture = supportedSizes[0];
              param.SetPictureSize(sizePicture.Height, sizePicture.Width);
              _camera.SetParameters(param);
  </code></pre>
  
  <p>But when I run the code this message shows up:</p>
  
  <blockquote>
    <p>Unhandled Exception:</p>
    
    <p>Java.Lang.RuntimeException: setParameters failed</p>
  </blockquote>
  
  <p>what is wrong here ? I can not set any of the supported sizes that the function returns ? how to I select any of them for instance the first? there is something else that I have to tke into account?</p>