O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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​(​)​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required