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
2
votes
0 answers

Camera preview and recorded video doesn't match the aspect ratio

I am trying to record a video using camera2 API but the Camera preview size and video are not the same as expected. The object appears centered in-camera preview but when the video is recorded, then the object is shifted to slightly. These are 2…
narender sharma
  • 561
  • 1
  • 4
  • 7
2
votes
0 answers

How to enable enableShutterSound on some devices?

I used "enableShutterSound" to get rid of the camera shutter sound. The problem is that it works fine on my device, but not on others' devices. Please can any one help, how can I mute camera shutter sound? Below is my code. Camera.CameraInfo info =…
SW C
  • 21
  • 4
2
votes
1 answer

Getting relative rotation from the camera sensor to the current device orientation

There are a couple of samples to get the relative rotation from the camera sensor to the current device orientation, e.g. for using it for correcting camera preview or for MediaRecorder.setOrientationHint(int) But the newest method from the latest…
user924
  • 8,146
  • 7
  • 57
  • 139
2
votes
1 answer

Cannot take picture on flutter camera because of "unconfigured surface"

I wanted to capture the image and display a preview screen showing the captured image. It worked fine before, but once I added object detection, I receive a group of errors every time I try to take a photo. I think the object detection is…
2
votes
2 answers

request camera permission only after button is clicked

I created an app where I have a place to put profile picture and it looks as follows: When the camera button is click there are two options: Now, I had like my app to ask the users if they allow me to grant camera permissions once they click on…
Ben
  • 1,737
  • 2
  • 30
  • 61
2
votes
0 answers

How to get a bitmap from camerax?

I need to get a bitmap correctly from ImageProxy and I tried several methods. I tried the following method for conversion ImageProxy to bitmap: class CustomBitmapConverter(context: Context) { private val rs =…
Viktor Vostrikov
  • 1,322
  • 3
  • 19
  • 36
2
votes
1 answer

Android CameraX how to rotate output video

I use the following versions of CameraX dependencies: implementation "androidx.camera:camera-camera2:1.0.0-beta04" implementation "androidx.camera:camera-view:1.0.0-alpha11" implementation…
2
votes
2 answers

Delay on the capture of an image with React Native Camera / Expo Camera, set 'processing message'?

I have a huge delay in my app from when a user takes a photo to when android processes the image. The issue of delay in Expo with android camera has been answered here: Delay on the capture of an image - React Native Camera / Expo Camera. I am…
Leon Segal
  • 679
  • 7
  • 28
2
votes
1 answer

Android Camera2 pipeline: How do I encode h.264 units using MediaCodec from an input Surface?

I have an Android application using the Camera2 API. The ultimate goal is to get h264 units to write to a stream. So far I have Successfully created a capture session and can write to preview, local recording and streaming surfaces via: …
2
votes
1 answer

Nativescript CameraPlus preview too zoomed in

I'm using Camera Plus with Nativescript Vue. The camera preview is very zoomed in, but when I take a photo it comes out normal. This only happens on Android. Anyone out there who have experience with this plugin and knows what the issue might be?…
2
votes
1 answer

How to capture image by custom button from already opened front camera

Im working on a augmented reality app which displays 3d models on the users face.I made a class which extends ArFragment in which i set the front camera to be opened once a model is selected.I made a custom button for capturing the image,but i dont…
2
votes
0 answers

Observing camera isFocusing || !isFocusing for androidx.camera.core.Camera

Is there any documentation you guys can help me drive me in the direction? I've only VERY recently implemented AndroidX as I was using the old Camera framework. I've only found one lead and it was a dead end. I guess I would like to be notified when…
insta catering
  • 151
  • 2
  • 12
2
votes
3 answers

Cannot Access Camera from Android 10 Web View

On upgrade to Android 10 the onShowFileChooser code I have been using inside my Hybrid Android Web View App since Android 5 or 6 stopped providing access to the camera. The user could still access stored photos, but the camera option was no longer…
Steve Brooker
  • 1,043
  • 11
  • 28
2
votes
1 answer

How to save image PERMANENTLY after using camera to take photo in android?

I know this has been posted here multiple times but none of the solutions is clear enough on what needs to be done. I guess it would help to know that I'm new to android programming. This is where I create the intent to use camera in the app. public…
sonofel
  • 112
  • 3
  • 8
2
votes
1 answer

Take picture with camera in android 10

With all of the changes in android 10 that are related to scoped storage, how can we open the camera. I saw some tutorial that suggest using a file provider, but I don't really quite get it. Can you provide a snippet of code to launch the camera…
ahmed osama
  • 560
  • 1
  • 7
  • 13