0

Could anyone provide a sample code for using the Camera API for Android 4.1 and 4.2 as given in this link: Link

I am currently using this code for older versions but it does not work in Jellybean devices

AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback() {

        @Override
        public void onAutoFocus(boolean arg0, Camera arg1) {
            // TODO Auto-generated method stub
            if (arg0) {
                if (mPreviewRunning) {
                    mCamera.takePicture(myShutterCallback, mPicture, mPicture);
                }

            } else {
                flKeepClean.setVisibility(View.VISIBLE);
                btnCamera.setEnabled(true);
                side.setEnabled(true);

            }

        }
    };


    ShutterCallback myShutterCallback = new ShutterCallback() {

        @Override
        public void onShutter() {
            // TODO Auto-generated method stub
        }
    };

AutoFocusMoveCallback

Vishal Pawar
  • 4,324
  • 4
  • 28
  • 54
Lincy
  • 1,033
  • 1
  • 8
  • 14
  • What do you mean with "it does not work"? In the takePicture method I would also either pass null for the raw callback, or pass different callbacks for raw and jpeg. – Hyndrix Dec 20 '12 at 05:56
  • As per how I understand it, for jellybean devices we need to use the Camera API as pointed out in this link:http://developer.android.com/about/versions/android-4.1.html#Camera – Lincy Dec 20 '12 at 06:05
  • onAutoFocus always take you to the else block when run on jellybean devices when used like I've done – Lincy Dec 20 '12 at 06:07

1 Answers1

0

Sorry for the late update. The issue was when the device didn't have autofocus. So you need to first check whether the device has autofocus : boolean focus = getPackageManager().hasSystemFeature( "android.hardware.camera.autofocus");

Lincy
  • 1,033
  • 1
  • 8
  • 14