Checking Whether You Can Take a Photograph

For the On Your Bike app, taking photos is a nice feature, but it isn’t essential. You can just check whether the device has a camera and provide a default app to handle taking photographs. Follow these steps.

1. Create a new Java class named Camera in the com.androiddevbook.onyourbike.chapter8.helpers package. In the constructor, change the function to accept a single parameter of type Activity, and log that it has been called (see Listing 8.4).

Listing 8.4 Creating the Camera Java Class

public class Camera {    public Camera(Activity activity) {        CLASS_NAME = getClass().getName();    }}

2. As you have done before, you will use the CLASS_NAME static string to store ...

Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications 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.