I have a FrameLayout in one of my screens. I refer to it in my code like this:
preview = (FrameLayout)findViewById(R.id.preview);
And I am embedding a CameraPreview object(extends SurfaceView, from the ZBar SDK for QR parsing) in the FrameLayout like this:
scanner.setConfig(0, Config.Y_DENSITY, 3);
mPreview = new CameraPreview(this, mCamera, getPreviewCallback(), autoFocusCB);
if(preview.getChildCount()>=1)
preview.removeAllViews();
preview.addView(mPreview);
Now when I run this on one of my test phones, Samsung Galaxy 3(GT-I5801), everything works fine and QRs are parsed ok. But if I scan it with a Samsung Galaxy S2 or Samsung Ace, the app initially starts with the camera either in low resolution or is unable to focus. Also it is unable to adjust its white balance automatically if I put it against a really bright screen. But the camera starts working fine if I navigate away from the Camera tab to another tab within the app and come back.
Any help with solving this would be greatly appreciated. Is it anything to do with the screen or camera resolution? Or anything in the ZBar SDK if anyone knows? Or what is almost always the case, I am missing something? Thanks again for reading through this far.