How to do it...

As you'll see, there's a lot of code for this recipe. Start by opening the Android Manifest and following these steps:

  1. Add the following two permissions:
<uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  1. Now, open activity_main.xml and replace the existing TextView with the following views:
<TextureView    android:id="@+id/textureView"    android:layout_width="match_parent"    android:layout_height="match_parent"    app:layout_constraintTop_toTopOf="parent"    app:layout_constraintBottom_toTopOf="@+id/button"    app:layout_constraintLeft_toLeftOf="parent"    app:layout_constraintRight_toRightOf="parent" /><    android ...

Get Android 9 Development Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.