0

I am trying to develop an Android application that will take pictures in a service. Before implementing a service I am trying to implement the functionality on a button click. I've used code available on following locations

how to capture an image in background without using the camera application

However I am getting an excecption while executing Camera.takePicture() call. The LogCat shows following

12-10 14:46:56.135 589-18809/? E/QCameraStateMachine: int32_t qcamera::QCameraStateMachine::procEvtPreviewReadyState(qcamera_sm_evt_enum_t, void *): Error!! cannot handle evt(24) in state(1)    
12-10 14:46:56.135 589-4574/? I/QCamera2HWI: [KPI Perf] static int qcamera::QCamera2HardwareInterface::pre_take_picture(struct camera_device *): X    
12-10 14:46:56.135 589-4574/? E/QCamera2HWI: static int qcamera::QCamera2HardwareInterface::take_picture(struct camera_device *): pre_take_picture failed with ret = -38    
12-10 14:46:56.135 589-4574/? I/QCameraHalWatchdog: Stopped Watchdog Thread (0ms)[take_picture]

I could not find any information on "cannot handle evt(24) in state(1)". Neither on "qcamera::QCamera2HardwareInterface::pre_take_picture(struct camera_device *): X"

I have not copied the code here since the code is already presnet in the link I've provided earlier

My min compile version is KitKat and I am using Motorola Lenovo.

Your help is highly appreciated.

Edit**** Here is the code

Camera.PictureCallback mCall = new Camera.PictureCallback() {
    public void onPictureTaken(byte[] data, Camera camera) {
        Log.d(TAG, "------ In onPictureTaken");
        // decode the data obtained by the camera into a Bitmap
        // display.setImageBitmap(photo);
        Bitmap bitmapPicture = BitmapFactory.decodeByteArray(data, 0,
                data.length);
    }
};

...

Camera c = null;
try {
        c = Camera.open();

        SurfaceView sv = new SurfaceView(this);
        SurfaceHolder holder = sv.getHolder();
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        c.setPreviewDisplay(holder);
        Camera.Parameters params = c.getParameters();
        params.setJpegQuality(100);
        c.setParameters(params);
        c.startPreview();

        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        c.setPreviewDisplay(holder);
        c.takePicture(null, null, mCall);
    } catch (Exception e) {
        Log.e(TAG, "---- problems with camera operation " + e.getMessage(), e);
        e.printStackTrace();
        Log.d(TAG, "------ 333333 ");
    } finally {
        if (c != null) {
            c.stopPreview();
            c.release();
        }
    }
vetal_king
  • 63
  • 7

0 Answers0