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.support.v7.widget.AppCompatButton    android ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.