Android Camera :

Most Android phones today include inbuilt cameras — one at the front and one at the rear. This example shows you the way to programmatically invoke the camera to take an image and then save the image to external storage.In this Android tutorial you will learn how to use in-build android camera to take picture.

Android camera tutorial example

Solution Steps Android Camera :

In this example we will use Android camera api  (Existing android camera application api), which is use existing camera application installed on your phone.You are using an Intent object to invoke the camera, using the MediaStore.ACTION_IMAGE_CAPTURE action.

1. Create Android New project (Click here for setup new Android project).

2. Add Following xml code into activity_main.xml

File : res/layout/activity_main.xml

3. Open “MainActivity.java” file and add following JAVA code.

File : src/package-name/MainActivity.java

Here, you’re using an Intent object to invoke the camera, using the MediaStore.ACTION_IMAGE_CAPTURE action. At the same time, you’re telling the camera that you want to save the captured image to external storage and name the saved image MyPhoto.jpg.

Finally, you call the startActivityForResult() method to fire the Intent object. This ensures that after the picture has been saved, its path are displayed using the Toast class. this is often done through the onActivityResult() callback function.

4. Open “AndroidManifest.xml” file and add <uses-feature>.

you need to add the <uses-feature> element to your AndroidManifest.xml file:

File : ProjectName/AndroidManifest.xml

To ensure that your application can only be installed on devices with a camera(it will not work with Android emulator).

Output of  Android Camera Api access Example :

Android Camera Tutorial example

Note : This example (Project) is developed in Eclipse Version Kepler,tested on Android 4.4.4 (KitKat Version) and SDK build-tools 24.1

MinSdkVersion=”14″

TargetSdkVersion=”21″

Download Android Camera Api example  Source code :


Leave a Reply