Android 4 - Camera White Balancing stops after autoFocus

android, autofocus, camera

Solution

I have ran into similar issue on Samsung Galaxy 2 Duos 2. In this case, the auto exposure settings have stopped working instead of the WB. I tried to cycle (on/off) the auto exposure param and it worked for me.

mCamera.autoFocus(new Camera.AutoFocusCallback() {

    @Override
    public void onAutoFocus(boolean b, Camera camera) {

        Camera.Parameters params = camera.getParameters();
        if (params.isAutoExposureLockSupported()) {
            params.setAutoExposureLock(true);
            camera.setParameters(params);

            params = camera.getParameters();
            params.setAutoExposureLock(false);
            camera.setParameters(params);
        }
     }

 });

Problem

In my current application, I've got a class holding an instance of a Camera object and trying to do the following: 1) Wait for a specified time, e.g. nothing (this is done via a TimerTask) 2) Request to focus via autoFocus 3) In autoFocus callback, request OneShotPreviewCallback 4) In preview callback, save image 5) Repeat While the white balancing is working fine prior to the first autoFocus, it stops after the first focussing has been done. Well, of course I looked up the API, and there is one interesting statement in the autoFocus description. But auto-focus routine may stop auto-exposure and auto-white balance transiently during focusing. But it seems it is non stopped only transiently, but permantly. Funny enough, with the subsequent call of autoFocus, the camera tries to ajust the whitening again, but the correct value is mostly only with the second or third autoFocus. I also tried to set the white balancing in code, but it didn't change anything. ``` setWhiteBalance(Camera.Parameters.WHITE_BALANCE_AUTO); ``` Does anyone else know this issue, or am I missing some point ? I know that I could permanently call autoFocus to force the white balancing, but that doesn't seem the optimal way for me, because prior to the first call auf autoFocus, it works perfectly fine. P.S.: I'm testing on a Samsung Galaxy S2 with Android 4.0.3.

Original source