The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Using the Camera via 3rd-Party Apps

Most Android devices will have a camera, since they are fairly commonplace on mobile devices these days. You, as an Android developer, can take advantage of the camera, for everything from snapping tourist photos to scanning barcodes. If you wish to let other apps do the “heavy lifting” for you, working with the camera can be fairly straightforward. If you want more control, you can work with the camera directly, though this control comes with greater complexity.

You can also record videos using the camera. Once again, you have the option of either using a third-party activity, or doing it yourself.

Prerequisites

Understanding this chapter requires that you have read the core chapters, particularly the material on implicit Intents. You also need to read the chapters on the ContentProvider component, particularly the coverage of FileProvider.

Being Specific About Features

If your app needs a camera — by any of the means cited in this chapter – you should include a <uses-feature> element in the manifest indicating your requirements. However, you need to be fairly specific about your requirements here.

For example, the Nexus 7 (2012) has a camera… but only a front-facing camera. This facilitates apps like video chat. However, the android.hardware.camera implies that you need a high-resolution rear-facing camera. Hence, to work with the Nexus 7’s camera, you need to:

At runtime, you would use hasSystemFeature() on PackageManager, or interrogate the Camera class for available cameras, to determine what you have access to.

Note that if you want to record audio when recording videos, you should also consider the android.hardware.microphone feature.

Still Photos: Letting the Camera App Do It

The preview of this section was eaten by a grue.

Permissions and Third-Party Camera Apps

The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).

A Matter of Orientation

The preview of this section was last seen in the Bermuda Triangle.

Scanning with ZXing

The preview of this section is sleeping in.

Videos: Letting the Camera App Do It

The preview of this section is presently indisposed.

Using a Camera Library

The preview of this section apparently resembled a Pokémon.

Directly Working with the Camera

The preview of this section is in the process of being translated from its native Klingon.