title: Switching to front camera not working
body: <p>Here is my whole activity code : 
      import java.io.IOException;</p>
  
  <pre><code>import pickld.android.intents.R;
  import android.app.Activity;
  import android.hardware.Camera;
  import android.os.Bundle;
  import android.view.SurfaceHolder;
  import android.view.SurfaceView;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.Window;
  import android.widget.Button;
  import android.widget.Toast;
  
  public class CameraActivity extends Activity implements SurfaceHolder.Callback, OnClickListener {
  
      Camera camera;
      SurfaceView surfaceView;
      SurfaceHolder surfaceHolder;
      boolean previewing = false;
  
      int camId = Camera.CameraInfo.CAMERA_FACING_BACK;
      int numberOfCamera;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          setContentView(R.layout.camera);
  
          surfaceView = (SurfaceView)findViewById(R.id.camerapreview);
          surfaceHolder = surfaceView.getHolder();
          surfaceHolder.addCallback(this);
          surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  
          Button cancel = (Button)findViewById(R.id.cancel);
          Button openGallery = (Button)findViewById(R.id.openGallery);
          Button takePhoto = (Button)findViewById(R.id.capture);
          Button switchCam = (Button)findViewById(R.id.flip);
          Button toggleFlash = (Button)findViewById(R.id.toggleFlash);
  
          cancel.setOnClickListener(this);
          openGallery.setOnClickListener(this);
          takePhoto.setOnClickListener(this);
          switchCam.setOnClickListener(this);
          toggleFlash.setOnClickListener(this);
  
      }
  
      public void openFrontFacingCamera() {
          numberOfCamera = Camera.getNumberOfCameras();
          if(camId == Camera.CameraInfo.CAMERA_FACING_BACK){
              camId = Camera.CameraInfo.CAMERA_FACING_FRONT;
              Toast.makeText(getApplicationContext(), "BACK TO FRONT" ,
  1000).show();
                  try {
                      camera = Camera.open(camId);
                      camera.setPreviewDisplay(surfaceHolder);
                      camera.startPreview();
                      previewing = true;
                  } catch (RuntimeException e) {
  
              } catch (IOException e) {}
          }else if(camId == Camera.CameraInfo.CAMERA_FACING_FRONT){
              camId = Camera.CameraInfo.CAMERA_FACING_BACK;
              Toast.makeText(getApplicationContext(), "FRONT TO BACK" , 
  
  
  
   1000).show();
                      try {
                          camera = Camera.open(camId);
                          camera.setPreviewDisplay(surfaceHolder);
                          camera.startPreview();
                      } catch (RuntimeException e) {
  
              } catch (IOException e) {}
          }
      }
  
      @Override
      public void onClick(View click) {
          if(click.getId() == R.id.cancel){
              this.finish();
          }else if(click.getId() == R.id.flip){
              openFrontFacingCamera();
          }
      }
  
  
      @Override
      public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
          if(previewing){
              camera.stopPreview();
              previewing = false;
          }
          if (camera != null){
              try {
                  camera.setPreviewDisplay(surfaceHolder);
                  camera.startPreview();
                  previewing = true;
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  
      @Override
      public void surfaceCreated(SurfaceHolder holder) {
          camera = Camera.open(camId);
          camera.setDisplayOrientation(90);
      }
  
      @Override
      public void surfaceDestroyed(SurfaceHolder holder) {
          camera.stopPreview();
          camera.release();
          camera = null;
          previewing = false;
      }
  
  }
  </code></pre>
  
  <p>Everytime i call the <code>openFrontFacingCamera()</code> method, every conditions seems to be working fine i can see it on the <code>Toast</code> i put there, but the camera itself is not switching. I think there must something missing or wrong with this line <code>camera = Camera.open(camId);</code> im not sure. Please help me. Thanks.</p>