Custom Camera using SurfaceView

Page 1

Custom Camera using SurfaceView SurfaceView is a class provided by android.view package. It offers a dedicated drawing surface embedded inside of a view hierarchy. We can manage the format of this surface, however, the SurfaceView takes care of putting the surface at the right location on the screen. In this post, we will use the SurfaceView to preview the camera (android.hardware.camera) onto the screen and capture images using it. First let us create a new project and add the following dependencies in your app level build.gradle file which is available at location: app/build.gradle.

1 dependencies { 2

/*... other dependencies ...*/

3

implementation 'com.google.android.gms:play-services-vision:17.0.2'

4}

In the AndroidManifest.xml file, add the following permission.

1 <uses-permission android:name="android.permission.CAMERA" />

We will also be needing the real-time permission check for android version M and above. Add the below code in your MainActivity.java for handling these checks.

1 import android.content.DialogInterface; 2 import android.content.pm.PackageManager; 3 import android.os.Bundle; 4 import android.support.annotation.NonNull;


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Custom Camera using SurfaceView by InnovationM (Top Mobile App & Web Development Company) - Issuu