Using the Camera API

Up to this point, you have been doing basic activity-creating. Now it is time to take on camera-specific concepts and classes.

Opening and releasing the camera

First, let’s handle the management of the camera resource. You have given CrimeCameraFragment an instance of Camera. The camera is an important system-wide resource, so it is critical to obtain it only when you need it and release it as soon as you are done. Otherwise, the camera will be unavailable to other applications until the device is rebooted.

Here are the Camera methods you will use to manage the Camera instance:

 ​ ​ ​ ​p​u​b​l​i​c​ ​s​t​a​t​i​c​ ​C​a​m​e​r​a​ ​o​p​e​n​(​i​n​t​ ​c​a​m​e​r​a​I​d​)​ ​ ​ ​ ​p​u​b​l​i​c​ ​s​t​a​t​i​c​ ​C​a​m​e​r​a​ ​o​p​e​n​(​)​ ...

Get Android Programming: The Big Nerd Ranch Guide 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.