title: Android Custom Camera doesn't respond after the first shot
body: <p>Recently, I've made a Custom Camera app for testing purposes, and I've encountered a minor problem that seemed simple, yet, hard for me to solve.
  The problem is that when I tap the button to take a snapshot the camera succeeds in capturing the photo on the first try, however, when I tap the button the second time, the camera doesn't respond at all (Doesn't crash but can't take the photo's)
  I've set up the sample code below , and I wonder if some code that I implemented has some structural errors or if I'm just a noob doing things that is off topic.</p>
  
  <pre><code>    preview = new Preview(this,
                  (SurfaceView) findViewById(R.id.CameraFragment));
          FrameLayout frame = (FrameLayout) findViewById(R.id.preview);
          frame.addView(preview);
          preview.setKeepScreenOn(true);
          fotoButton.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  try {
                      //take the picture 
                      takeFocusedPicture();
  
                  } catch (Exception e) {
  
                  }
                  // exitButton.setClickable(false);
                  fotoButton.setClickable(false);
                  // progressLayout.setVisibility(View.VISIBLE);
  
              }
          });
      }
  
  
      @Override
      protected void onResume() {
          super.onResume();
          // TODO Auto-generated method stub
          if (camera == null) {
              camera = Camera.open();
              camera.startPreview();
              camera.setErrorCallback(new ErrorCallback() {
                  public void onError(int error, Camera mcamera) {
  
                      camera.release();
                      camera = Camera.open();
                      Log.d("Camera died", "error camera");
  
                  }
              });
          }
          if (camera != null) {
              if (Build.VERSION.SDK_INT &gt;= 14)
                  setCameraDisplayOrientation(context,
                          CameraInfo.CAMERA_FACING_BACK, camera);
              preview.setCamera(camera);
          }
      }
  
  
  //This method allows you to take the image after the camera autofocuses
      Camera.AutoFocusCallback mAutoFocusCallback = new Camera.AutoFocusCallback() {
          @Override
          public void onAutoFocus(boolean success, Camera camera) {
  
              try {
                  // camera.takePicture(mShutterCallback, null, jpegCallback);
                  shutter(); // Method one shutt(1)
              } catch (Exception e) {
  
              }
  
          }
      };
  
  
  
      //This method will activate the shutter class 
      public void shutter() {
          //passies the auto focus listener  parameter = 2 
          this.camera.autoFocus(this.mAutofocusListener);
      }
  
  
      private Camera.AutoFocusCallback mAutofocusListener = new Camera.AutoFocusCallback() {
  
          @Override
          public void onAutoFocus(boolean success, Camera camera) {
              // camera.autoFocus(null); Takes the picture after the device succeeds in auto focus 
  
              //passes in two methos as a parameter 
               //First parameter  = 3 Second paramter = 4 
              camera.takePicture(mShutterListener, null, mPictureListener);
          }
      };
  
  
      private Camera.ShutterCallback mShutterListener = new Camera.ShutterCallback() {
  
          @Override
          public void onShutter() {
  
          }
      };
  
      //method for the picture callback parameter = 4
      private Camera.PictureCallback mPictureListener = new Camera.PictureCallback() {
  
  
          //I think you better alter this part 
          @Override
          public void onPictureTaken(byte[] data, Camera camera) {
  //returns the image data as a byte
              //if image data exists 
          //  if (data != null) {
                  camera.startPreview();
  
                  //passes in the byte data into the makeRotateImage function to rotate the image that has been taken 
                  makeRotateImage(mOwner, data, 512 * 512); //maximum pixel willl be 262144
  
              //}
          }
      };
  
      public void takeFocusedPicture() {
          //sets up the mAutoFocusCallback method as a parameter 
          camera.autoFocus(mAutoFocusCallback);
  
      }
  </code></pre>