Virtually every Android device is equipped with at least one digital camera and it's nice to be able to take control of this equipment and take photographs directly from within an application. Although the android.hardware.Camera class makes it simple to take an actual photo, the preparation of the camera preview is relatively more complex.
In this exercise we will construct a SurfaceView that will take a photograph when tapped. Be warned that there is more typing involved in this task than most.
All you will need to prepare for this recipe is to start a new Android project in Eclipse. Make your way to the AndroidManifest
file.
Use of the camera requires for permissions to be granted. Add the following lines to the Manifest file at the same level as the
<application>
tag:<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" />
We need only one view in...