title: Capture image without intent, Gives different output on different devices
body: <p>My requirement is neither to display camera preview nor to use camera intent for image capture.</p>
  
  <p>There for I find a way which is working for my first testing device (Galaxy tab 7").</p>
  
  <p>My <code>CaptureImage</code> function is as below</p>
  
  <pre><code>private void CaptureImage() {
          int FrontCameraFound = getCameraID();
          if (FrontCameraFound != -1) {
              mCamera = Camera.open(FrontCameraFound);
  
              parameters = mCamera.getParameters();
  
              mCamera.setParameters(parameters);
              mCamera.startPreview();
  
              Camera.PictureCallback mCall = new Camera.PictureCallback() {
                  @Override
                  public void onPictureTaken(byte[] data, Camera camera) {
  
                      bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
  
                      // set bitmap tp image view just to check 
                      // if image capture proper, testing purpose
                      iv_image.setImageBitmap(bmp);
  
                      mCamera.stopPreview();
                      mCamera.release();
                      mCamera = null;
                  }
              };
              mCamera.takePicture(null, null, mCall);
          }
      }
  </code></pre>
  
  <p>and <code>getCameraID</code> function as below</p>
  
  <pre><code>private int getCameraID() {
      Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
  
      for (int camIdx = 0; camIdx &lt; Camera.getNumberOfCameras(); camIdx++) {
          Camera.getCameraInfo(camIdx, cameraInfo);
          // for capture image from back camera
          // If want to capture from front 
          // then change it to CAMERA_FACING_FRONT
          if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
              try {
                  return camIdx;
              } catch (RuntimeException e) {
  
              }
          }
      }
      return -1;
  }
  </code></pre>
  
  <p>Now I am facing difficulty to run successfully above code on different devices.</p>
  
  <ul>
  <li>Samsung Galaxy S+ (2.3.6) : Front camera always return green image but coding for Back camera working fine.</li>
  <li>Samsung Galaxy Nexus (4.1) : coding doesn't work Neither for Front nor for Back camera &amp; gives "takePicture" failed.</li>
  <li>LG Optimus Net (2.3.4) : only back camera is there &amp; working fine.</li>
  <li>Samsung Galaxy Tab 7 " (2.3.3) : both camera working fine.</li>
  <li>Motorola Xoom (3.1) : both camera working fine.</li>
  </ul>
  
  <p>Logcat of Samsung Galaxy Nexus :</p>
  
  <pre><code>09-21 09:37:42.125: E/AndroidRuntime(4647): Caused by: java.lang.RuntimeException: takePicture failed
  09-21 09:37:42.125: E/AndroidRuntime(4647):     at android.hardware.Camera.native_takePicture(Native Method)
  09-21 09:37:42.125: E/AndroidRuntime(4647):     at android.hardware.Camera.takePicture(Camera.java:1061)
  09-21 09:37:42.125: E/AndroidRuntime(4647):     at android.hardware.Camera.takePicture(Camera.java:1006)
  09-21 09:37:42.125: E/AndroidRuntime(4647):     at fortyonepost.com.pwop.TakePictureDemoActivity.CaptureImage(TakePictureDemoActivity.java:63)
  09-21 09:37:42.125: E/AndroidRuntime(4647):     at fortyonepost.com.pwop.TakePictureDemoActivity.onCreate(TakePictureDemoActivity.java:36)
  09-21 09:37:42.125: E/AndroidRuntime(4647):     at android.app.Activity.performCreate(Activity.java:5008)
  09-21 09:37:42.125: E/AndroidRuntime(4647):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  09-21 09:37:42.125: E/AndroidRuntime(4647):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  </code></pre>
  
  <p>It is not possible to check code for every devices , I just test my code on 5 devices and 2 device causes problem, so is there any standard way to fetch image from camera without intent &amp; preview.</p>
  
  <p>Please note that I include  in manifest &amp; set minimum sdk version to 9</p>
  
  <p><strong>Update :</strong>
  In 4.1 Nexus Galaxy <code>takePicture Failed</code> from Line number 1061 in Camera.java class, here is the <a href="https://github.com/android/platform_frameworks_base/blob/master/core/java/android/hardware/Camera.java#L1061" rel="noreferrer">class link</a> which gives me information that <code>native_takePicture(msgType); function in Camera.java</code> did throw that</p>