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
59
votes
5 answers

Android image resizing and preserving EXIF data (orientation, rotation, etc.)

If your Android app uses the device camera to take a picture and then resizes it (this is very, very common to reduce the size for upload), you might not realize that this resize operation strips the Exif metadata. This can cause problems,…
Mike Repass
  • 6,825
  • 5
  • 38
  • 35
58
votes
5 answers

Android camera2 face detection

There is not enough info about camera2 face detection mechanism. I used the Camera2 sample from Google: https://github.com/android/camera-samples I set face detection mode to…
58
votes
9 answers

Taking picture from camera without preview

I am writing an Android 1.5 application which starts just after boot-up. This is a Service and should take a picture without preview. This app will log the light density in some areas whatever. I was able to take a picture but the picture was black.…
eyurdakul
  • 894
  • 2
  • 12
  • 29
57
votes
14 answers

android java lang runtimeexception fail to connect to camera service

I am currently working on Flashlight On/OFF. I am getting this error java.lang.RuntimeException: Fail to connect to camera service I don't know why this error is occurring. I referred to many solutions but my problem was still not solved. When…
Jigar Shekh
  • 2,800
  • 6
  • 29
  • 54
55
votes
6 answers

How to autofocus Android camera automatically?

I want to autofocus Android camera as soon as camera holds still. Im looking for tutorials or samples how to do it or at least small sample that shows what classes I can use to hook on such events.
Alexey Zakharov
  • 24,694
  • 42
  • 126
  • 197
53
votes
7 answers

Use camera flashlight in Android

I'm trying to use the cameras LED flashlight in a widget. I've found several threads about this topic (i.e. the one mentioned later..) , now I'm trying to control the light using: Camera cam = Camera.open(); Parameters p =…
pgruetter
  • 1,184
  • 1
  • 11
  • 29
48
votes
2 answers

FileProvider Not Working with Camera

I'm trying to make Camera App to store the output to my internal storage. I also understand that third party apps are not able to access the Internal Storage of my application BUT we are able to do so by exposing the internal directory through…
You Qi
  • 8,353
  • 8
  • 50
  • 68
48
votes
1 answer

Apply effect to video frame captured by camera

I noticed that there is android.media.effect for developer to use in api level 17. There is also a sample 'Helloeffect' for developer to render. However, the sample is focus on a picture. I read the file of effect class and found it must apply an…
Brendon Tsai
  • 1,267
  • 1
  • 17
  • 31
46
votes
5 answers

java.lang.RuntimeException: takePicture failed

when i do continuous click on Capture button (without any break), getting Runtime Exception how can i resolve this issue ? if its not possible so how may i handle this Exception ? btnCapture = (ImageButton) findViewById(R.id.btnCapture); …
Sun
  • 6,768
  • 25
  • 76
  • 131
45
votes
6 answers

How to measure height, width and distance of object using camera?

I referred lot many links but still I am not able to get any point from that I can start my development. I want to measure my image height, width and distance using camera. I found this app . I want to make this type of application not exactly same…
anddev
  • 3,144
  • 12
  • 39
  • 70
45
votes
4 answers

Correct handling of exception: "getParameters failed (empty parameters)"

I have a camera app in the Google Play store with Google Analytics installed. I keep getting the following crash report: getParameters failed (empty parameters) My question is: What is the correct way to handle this? Looking into the Android…
Grimmace
  • 4,021
  • 1
  • 31
  • 25
44
votes
11 answers

Get the file extension from images picked from gallery or camera, as string

I want to get as string the image extension (for example "jpg", "png", "bmp" ecc.) of the images loaded from the gallery or picked from the camera. I have used a method in this form to load images from the gallery private static final int…
AndreaF
  • 11,975
  • 27
  • 102
  • 168
44
votes
17 answers

Flutter camera appears stretched

I've been playing around with flutter an i'm loving it so far, but I'm having an issue getting the camera working. I follow the directions on this page https://pub.dartlang.org/packages/camera and it works. However, the camera is stretched so that…
Angus Allman
  • 511
  • 1
  • 6
  • 10
43
votes
1 answer

What can I do when the BufferQueue has been abandoned?

I am using a texture view to show the preview of the camera in my android app. What I noticed, however, is that every time my app gets paused, I am getting this error: 03-18 18:23:44.315: W/BufferQueue(19582): [unnamed-19582-20] cancelBuffer:…
user2426316
  • 7,131
  • 20
  • 52
  • 83
43
votes
13 answers

How to compress image size?

I want to capture image in low resolution using android camera api but when I captured image it will take default resolution of device camera.So I want to capture image in low resolution or small size at time of capture or how can I compress big…