The first step is to create a SurfaceView. It’ll receive camera data and display it inside the FrameLayout.
Create a new file, CameraView.java in the same folder that your MainActivity.java is.
First, just extend the SurfaceView and implements the SurfaceHolder.Callback.
You’ll have something like this code: