0

I want to display what Android camera films on the mCameraView:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mCameraView = (SurfaceView) findViewById(R.id.camera_view);

    openCamera();
}

The following code opens the camera:

void openCamera() {
    CameraManager manager = (CameraManager) this.getSystemService(
                            Context.CAMERA_SERVICE);
    try {
        String cameraId = manager.getCameraIdList()[0];
        manager.openCamera(cameraId, new StateCallback() {
            .... // Other override methods

            @Override
            public void onOpened(CameraDevice camera) {
                // What to type here???
            }

        }, new Handler(cameraThread));

    } catch (SecurityException | CameraAccessException exception) {
        throw new RuntimeException(exception);
    }
}

How to put what CameraDevice displays into the mCameraView?

mercury0114
  • 1,341
  • 2
  • 15
  • 29

1 Answers1

0

You can use a surfaceview to display the data. Check the answer here to see how the surfaceview works. https://stackoverflow.com/a/18299259/2363425

mremremre1
  • 1,036
  • 3
  • 16
  • 34