Capturing photos from the camera
To use the device camera, we need to access the Ti.Media
namespace, and specifically the showCamera
method. This will display the native operating system interface for taking photographs, and expose the three events that we need to decide what to do with the capture image. We will also check whether the user's device is capable of taking camera shots before we attempt to do all this, as some devices (including iPod Touch and simulators) don't have this capability.
Note
Note that if you're testing on iOS, this recipe will work only if you use a physical device! For Android, you should use the Genymotion simulator (https://www.genymotion.com/) and not the stock Android emulator. Genymotion is faster, integrates with Appcelerator Studio, and supports camera emulation.
The complete source code for this recipe can be found in the /Chapter 4/Recipe 2
folder.
How to do it...
We are going to extend the event listener of our OptionDialog
using the following code:
//add...