Questions tagged [android-camera]

The Android framework includes support for various cameras and camera features available on devices, allowing you to capture pictures and videos in your applications.

The Android framework includes support for various cameras and camera features available on devices, allowing you to capture pictures and videos in your applications.

Official Android Camera documentation

To access the device camera, you must declare the CAMERA permission in your Android Manifest. Also be sure to include the manifest element to declare camera features used by your application. For example, if you use the camera and auto-focus feature, your Manifest should include the following:

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

The Android framework supports capturing images and video through the Camera API or camera Intent.

  • Camera This class is the primary API for controlling device cameras. This class is used to take pictures or videos when you are building a camera application.
  • SurfaceView This class is used to present a live camera preview to the user.
  • MediaRecorder This class is used to record video from the camera.
  • Intent An intent action type of MediaStore.ACTION_IMAGE_CAPTURE or MediaStore.ACTION_VIDEO_CAPTURE can be used to capture images or videos without directly using the Camera object.

The Camera class has been deprecated. It is recommend using the newer class camera2, which works on Android 5.0 (API level 21) or greater.

You can read more about camera2 on Android Official blog. For questions specifically related to camera2, use .

6513 questions
255
votes
12 answers

How to turn on front flash light programmatically in Android?

I want to turn on front flash light (not with camera preview) programmatically in Android. I googled for it but the help i found referred me to this page Does anyone have any links or sample code?
saiket
  • 3,063
  • 5
  • 18
  • 10
156
votes
16 answers

Allow user to select camera or gallery for image

What I'm trying to do seems very simple, but after a few days of searching I can't quite figure it out. I have an application that allows the user to select multiple(up to 5) images. I'm using an ImageView. When the user clicks on the ImageView,…
146
votes
11 answers

Android Camera : data intent returns null

I have an android application which contains multiple activities. In one of them I'm using a button which will call the device camera : public void onClick(View view) { Intent photoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); …
soft_developer
  • 1,499
  • 2
  • 11
  • 9
143
votes
15 answers

Android Camera Preview Stretched

I've been working on making my custom camera activity on Android, but when rotating the camera, the aspect ratio of the surface view gets messed up. In my oncreate for the activity, I set the framelayout which holds the surface view that displays…
scientiffic
  • 9,045
  • 18
  • 76
  • 149
136
votes
7 answers

How to use Android's camera or camera2 API to support old and new API versions without deprecation notes?

The new camera2 API confuses me. I want to develop an app (for Android APIs 10 - 21) which uses the device's camera. As stated here, I should use the "Camera" API. However, when I try to add the "Camera" API (android.hardware.Camera) to the…
Gee
  • 1,465
  • 2
  • 10
  • 7
108
votes
5 answers

Android camera android.hardware.Camera deprecated

if android.hardware.Camera is deprecated and you cannot use the variable Camera, then what would be the alternative to this?
raja121
  • 1,129
  • 2
  • 8
  • 16
99
votes
7 answers

Android camera intent

I need to push an intent to default camera application to make it take a photo, save it and return an URI. Is there any way to do this?
Alexander Oleynikov
  • 19,190
  • 11
  • 37
  • 51
85
votes
10 answers

How do I open the "front camera" on the Android platform?

More generally, if a device has more than one embedded camera, is there a way to initialize one of them in particular? I didn't find it in Android reference…
Sol
  • 907
  • 1
  • 7
  • 5
84
votes
15 answers

Check if device has a camera?

In my app, I'd like to use the camera, if the device has one. Are there any devices running android that do not have a camera? By including the following into my manifest:
mark
  • 1,697
  • 3
  • 14
  • 13
73
votes
9 answers

Android M Camera Intent + permission bug?

I'm trying to get my app ready for the new Android M permissions changes and found some weird behaviour. My app uses the Camera intent mechanism to allow the user to get a picture form the camera. But in another activity needs to make use of the…
71
votes
7 answers

Android emulator camera custom image

Does anybody know is it possible to open some personal picture when emulator camera starts? I have an application which is based on image analysis and I would like when I click a button for camera that camera opens not that default Android emulator…
Cristiano
  • 3,099
  • 10
  • 45
  • 67
66
votes
11 answers

Camera activity returning null android

I am building an application where I want to capture an image by the default camera activity and return back to my activity and load that image in a ImageView. The problem is camera activity always returning null. In my onActivityResult(int…
rawcoder064
  • 1,374
  • 3
  • 11
  • 26
66
votes
13 answers

How to get file name from file path in android

I want to get file name from sdcard file path. e.g. :/storage/sdcard0/DCIM/Camera/1414240995236.jpg I want get 1414240995236.jpg I have written the code to fetch the same but it is not working. Please help. Below is my code: @Override protected…
Manikandan K
  • 1,081
  • 1
  • 9
  • 17
66
votes
6 answers

How to get camera result as a uri in data folder?

I am creating an application in which I want to capture a image and then I want to send that image in the email as a attachment. I am opening a camera using android.provider.MediaStore.ACTION_IMAGE_CAPTURE intent action and I am passing the Uri of…
Dharmendra
  • 33,296
  • 22
  • 86
  • 129
60
votes
9 answers

Controlling the camera to take pictures in portrait doesn't rotate the final images

I'm trying to controlling the Android camera to take pictures in a portrait app, but when I save the picture, it's in landscape. I've rotated the image 90 grades with setCameraDisplayOrientation() method, but doesn't work. Then I've found this post…
beni
  • 3,019
  • 5
  • 35
  • 55
1
2 3
99 100