android-camera

Picture file captured with camera intent empty for a while in onActivityResult

删除回忆录丶 提交于 2019-12-23 09:28:05
问题 I am having a very strange bug trying to take a picture via intent. Activity code (a little simplified): private void startCapture() throws IOException { // Create output file final File photoFile = makePhotoFile(); _photoPath = photoFile.getAbsolutePath(); Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); /* IMPORTANT NOTE TO READERS * As of Android N (which went out shortly after I posted this question), * you cannot use Uri.fromFile this way anymore. * You should use a

How to read length of video recorded with MediaRecorder into private app storage directory constructed via context.getFilesDir()?

你说的曾经没有我的故事 提交于 2019-12-23 07:55:50
问题 I am having a weird issue reading the length/duration of a video file recorded with a device's camera by using MediaRecorder. The file is recorded into the application's private storage directory, which is set like so: mMediaRecorder.setOutputFile(context.getFilesDir() + "/recordings/webcam.3gpp"); After recording is complete, I attempt to read the length of the video with these methods: Method 1: MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();

Camera FLASH_MODE_ON not working on Moto X

梦想的初衷 提交于 2019-12-23 07:48:01
问题 I have a button that toggles the flash mode between FLASH_MODE_ON / FLASH_MODE_OFF . The toggle works on most phones (I've tested on Nexus 5, S4 & S3) but it fails to flash when taking a picture on Moto X. Any ideas what could be the cause of this? // Set camera params final Camera.Parameters params = mCamera.getParameters(); final boolean shouldFlashBeOn = !(Camera.Parameters.FLASH_MODE_ON.equals(params.getFlashMode())); params.setFlashMode(shouldFlashBeOn ? Camera.Parameters.FLASH_MODE_ON :

Camera FLASH_MODE_ON not working on Moto X

烈酒焚心 提交于 2019-12-23 07:45:02
问题 I have a button that toggles the flash mode between FLASH_MODE_ON / FLASH_MODE_OFF . The toggle works on most phones (I've tested on Nexus 5, S4 & S3) but it fails to flash when taking a picture on Moto X. Any ideas what could be the cause of this? // Set camera params final Camera.Parameters params = mCamera.getParameters(); final boolean shouldFlashBeOn = !(Camera.Parameters.FLASH_MODE_ON.equals(params.getFlashMode())); params.setFlashMode(shouldFlashBeOn ? Camera.Parameters.FLASH_MODE_ON :

Camera Result always returns RESULT_CANCELED

半城伤御伤魂 提交于 2019-12-23 07:10:17
问题 I want to take pictures with my camera. I just need them temporally so i do the following: private void takePicture() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(this.getActivity().getPackageManager()) != null) { try { this.imageFile = File.createTempFile("CROP_SHOT", ".jpg", this.getActivity().getCacheDir()); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(this.imageFile)); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); this

CamcorderProfile.videoCodec returning wrong value

走远了吗. 提交于 2019-12-23 07:07:25
问题 According to the docs, you can use CamcorderProfile to get the devices default video codec format, then set it to MediaRecorder , like this: CamcorderProfile mProfile = CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_HIGH); // mMediaRecorder.setVideoEncoder(mProfile.videoCodec); But for some reason it is returning the wrong format. I'm using the CameraView library and in the FullVideoRecorder class the following is defined: switch (mResult.getVideoCodec()) { case H_263: mMediaRecorder

Camera Preview stretched when using FrameLayout

谁都会走 提交于 2019-12-23 05:44:05
问题 I have found that the CameraPreview is displayed in a small area when I use the PreviewFrameLayout and is stretched when I use the aspect ratio and the FrameLayout . Here is the code that I currently use to set the Camera Preview and the FrameLayout size: private Size getOptimalPreviewSize(Activity currentActivity, List<Size> sizes, double targetRatio) { // Use a very small tolerance because we want an exact match. final double ASPECT_TOLERANCE = 0.001; if (sizes == null) return null; Size

Android activity to open camera and upload an image to a server [duplicate]

隐身守侯 提交于 2019-12-23 05:15:42
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Calling camera from an activity, capturing an image and uploading to a server Here is the code i got on internet: package com.android.imageuploader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import com.android.imageuploader.R; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory;

Why image is being saved in Landscape Mode?

旧街凉风 提交于 2019-12-23 05:12:16
问题 In my code all is going well but clicked Image is being saved in Landscape Mode in given Directory. I have tried my best. Please help and suggest me to resolve this issue. The complete Code is given below with Print screen. or download from here https://www.dropbox.com/sh/vp6ohly4zb5vmvq/AACOyS8PvsRxFGBP9zjlVWhza?dl=0 Image saved in SDcard even captured in portrait it appear in landscape public class AndroidCamera extends Activity implements SurfaceHolder.Callback{ Camera camera; SurfaceView

No Activity found to handle MediaStore.ACTION_IMAGE_CAPTURE Intent

人走茶凉 提交于 2019-12-23 04:46:13
问题 I am using this quite simple piece of code to capture an image on an Android device. File tmpFile = ...; Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile)); startActivityForResult(intent, CAPTURE_IMAGE); This works fine for thousands of users except for one running this on a Kindle device without camera. Today I got a crash report from a device with camera: ANDROID_VERSION=4.2.1 BRAND=Hisense PHONE_MODEL=M470BSA STACK