Monday , December 10 2018
Home / Android / Android Camera Tutorial

Android Camera Tutorial

Camera is mainly used to capture picture and video. We can control the camera by using methods of camera api.

Android provides the facility to work on camera by 2 ways:

1) By Camera Intent
2) By Camera API
Understanding basic classes of Camera Intent and API

There are mainly four classes that we are going to discuss.

1) Intent

By the help of 2 constants of MediaStore class, we can capture picture and video without using the instance of Camera class.

ACTION_IMAGE_CAPTURE
ACTION_VIDEO_CAPTURE

2) Camera

It is main class of camera api, that can be used to take picture and video.

3) SurfaceView

It represents a surface view ore preview of live camera.

4) MediaRecorder

It is used to record video using camera. It can also be used to record audio files as we have seen in the previous example of media framework.

Android camera app example by camera intent

Here is an example that shows how to launch the existing camera application to capture an image and display the result in the form of bitmap

To experiment with this example , you need to run this on an actual device on which camera is supported.

 1) MainActivity.java

2) activity_main.xml 

3)  res/values/strings.xml

4) AndroidManifest.xml 

 

Preview

camera-w21

camera3

About admin

Check Also

Android Activity Launch Modes

Launch mode is an instruction for Android OS which specifies how the activity should be ...

Leave a Reply