title: Android Autofocus Callback in the Dark
body: <p>I have some trouble with the onAutoFocus callback of the Android Camera API. In the constructor of my Preview class I set the focus mode to FOCUS_MODE_AUTO and the flash mode to FLASH_MODE_AUTO. The button I present to the user to take a picture has a custom animation attached to it. When the user pressed the button, the animation starts and so does the auto focus:</p>
  
  <pre><code>public void onAnimationStart(Animation animation) {
      isAutoFocusing = true;
      AutoFocusCallBackImpl autoFocusCallBack = new AutoFocusCallBackImpl();
      camera.autoFocus(autoFocusCallBack);
  }
  </code></pre>
  
  <p>Then in the onAutoFocus method I take the picture:</p>
  
  <pre><code>public void onAutoFocus(boolean success, Camera camera) {
      if (camera != null) {
          try {
              camera.takePicture(shutterCallback, rawCallback, jpegCallback);
          } catch(Exception e) {
               // If something went wrong, we return
              // the user to the dashboard.
              setResult(Constants.PICTURE_CAMERA_ERROR);
              finish();
          }
      }
  }   
  </code></pre>
  
  <p>This works perfectly when there is enough light (so without the flash). In the dark however, the flash goes off and the picture is taken, but it appears that the camera did not focus properly. I know that the onAutoFocus callback is called immediately if auto focus isn't supported by the camera, but that clearly isn't the case here. Is auto focus impossible in the dark (even with the flash)?</p>