Camera Preview Example In Android Programming

Camera Preview Example in Android Programming

This example explains how you can use camera apis and create camera preview in you applications.


1.) Create a new project by File-> New -> Android Project name it CameraPreviewExample.

2.) Write following permissions into your manifest xml:

[code lang=”java”]


3.) Create and write following into res/menu/camera_menu.xml:




4.) Run for output.


1.) Create a project named CameraPreviewExample and set the information as stated in the image.

Build Target: Android 4.0
Application Name: CameraPreviewExample
Package Name: com. example. CameraPreviewExample
Activity Name: CameraPreviewExample
Min SDK Version: 14

2.) Open file and write following code there:




3.) Compile and build the project.


Comments 6

  1. Hello. Your code works perfect. I have tried using OnFramePreview to save frames on disk but i haven’t managed to do it. Is it possible using this kind of code? (Your code has Viewgroup in it, i used a similar in the past using surface view but that does not work on my new phone). I will appreciate your reply, as i have spend days of trying to accomplish this.

Leave a Reply

Your email address will not be published. Required fields are marked *