The Kotlin Camera2 API Rear Display Preview Android development tutorial describes how to display the rear camera to the preview display.
In the previous Kotlin on Android tutorial, we discussed how to successfully connect to the camera device.
In this Kotlin on Android tutorial we will cover:
- Adding aditional camera features to the Android Manifest file
- Creating CameraCaptureSession & CaptureRequest objects
- Displaying the rear camera
- Cleaning up CameraCapureSession & CaptureRequest objects
- Associating tags with Android Fragments
Thes Kotlin specific parts will include
- Checking if lateinit var is initialized (Kotlin 1.2)
- How to reference a property on Kotlin
- Using Kotlin when expressions
- Using Kotlin if expressions
- Kotlin safe casts
- Create TextureView
- Camera2 EasyPermissions
- Get Id for Camera Device
- Connect to Camera Device
- Display Rear Camera
- Display front Camera (Premium)
- Using Preview with SurfaceView (Premium)
In this Kotlin on Android tutorial, we introduced the CameraCaptureSession & CaptureRequest objects.
To create a configured camera capture request, a CameraCapture.Builder was created from the CameraDevice.
Then the surfaces were added to the CameraCapture.Builder object.
The CameraDevice was then used to create the capture session. With the CameraCaptureSession.StateCallback passed.
If the creation of the camera capture session was successful, the state callback’s onConfigured method would be called with configured camera capture session.
With the camera capture session, a repeating request can be made to display the rear camera.
The following Kotlin on Android tutorial describes how to display the front camera.
Switching between both cameras is also provided by using the Android navigation drawer.
The next episode is part of the Kotlin Camera2 premium products but can be bought of a one-off fee of 10.00 USD.
This will also include future Kotlin Camera2 premium episodes and immediate access to all future camera2 API series.