Snap and Save Pictures

To snap pictures and save them to the external storage of our device, we’ll first need to add a savePhoto method to the previous sketch here. The method takes care of capturing the image and writing it to the device’s external storage in a folder that bears the app’s name. When the photo is written to this public directory on the SD card, we receive a callback from onSavePhotoEvent notifying us that the writing process is complete. This callback method is also useful if we’d like to notify the device’s media library to make the photos available to other applications, which we accomplish with a call to the addToMediaLibrary method. Once we’ve added photos to the media library, we can browse them in the Gallery—Android’s ...

Get Rapid Android Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.