Search code examples
androidandroid-camera2

android camera2 createCaptureSession deprecated


CameraDevice.createCaptureSession is mostly deprecated. Any example on how to use the left over version method with the SessionConfiguration argument (and there especially the executor argument), would be nice.

Currently I have:

cameraDevice.createCaptureSession(surfaceList, mCameraSessionListener, mCameraHandler);

Solution

  • If you do not want to use any executor capabilites you can use a HandlerExecutor:

    SessionConfiguration sessionConfiguration = new SessionConfiguration(SessionConfiguration.SESSION_REGULAR, Collections.singletonList(outputConfiguration), new HandlerExecutor(mCameraHandler.getLooper()), mCameraSessionListener);
    cameraDevice.createCaptureSession(sessionConfiguration);