Questions tagged [android-camera-intent]

Questions related about calling the camera app from the local device, without the camera permission.

The camera intent is a way to make photos or videos with the camera app of the device without implementing a custom camera activity.

Here is a basic example for such a call:

// create Intent to take a picture and return control to the calling application
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

See the full code on the documentation.

971 questions
35
votes
5 answers

How to capture an image and store it with the native Android Camera

I am having a problem capturing an image and storing it from the native camera app. Here is a sample of some of my code. _path = Environment.getExternalStorageDirectory() + "make_machine_example.jpg"; File file = new File( _path ); Uri…
35
votes
3 answers

android camera : Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity

i've really frustased to solve my problem, i have an application that using camera, when camera capture a photo, it will display on activity, when i'm not using cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mPhotoUri); photo will display on…
Aoyama Nanami
  • 2,532
  • 9
  • 32
  • 50
35
votes
4 answers

Activity killed / onCreate called after taking picture via intent

I am trying to take a picture using an intent. My problem is that sometimes after taking a picture my activity, which calls startActivityForResult, seems to be destroyed so that onCreate is called again. Here is my code for taking pictures after…
27
votes
1 answer

What's the difference between ActivityCompat and ContextCompat?

I'm trying to use the Android camera, for API 23 or above, it requires asking for permission at runtime. According to the documentation, I can accomplish that using, ActivityCompat or ContextCompat. I don't understand what are the difference between…
25
votes
4 answers

Get Path of image from ACTION_IMAGE_CAPTURE Intent

Hi I am using ACTION_IMAGE_CAPTURE for capturing image using Intent as follows: Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra( MediaStore.EXTRA_OUTPUT, (new…
iCoder86
  • 1,874
  • 6
  • 26
  • 46
22
votes
5 answers

Android - Save images in an specific folder

I need to save the pictures taken with my app in an specific folder. I've read many solutions to this problem but I couldn't make any of them work so I ask for help. MainActivity.java public void onClick(View v) { Intent camera = new Intent( …
21
votes
4 answers

Take a photo automatically without user interaction

I used this code to capture an image from the camera. package android.takeowneship; import java.io.File; import android.app.Activity; import android.content.ContentValues; import android.content.Intent; import android.database.Cursor; import…
9T9
  • 698
  • 2
  • 9
  • 22
21
votes
2 answers

Camera Intent not saving photo

I successfully have used this code snippet before, but with the file pointing to somewhere on the SD card. final File temp = new File(getCacheDir(), "temp.jpg"); temp.delete(); Intent intent = new…
sgarman
  • 6,152
  • 5
  • 40
  • 44
21
votes
8 answers

android reduce file size for camera captured image to be less than 500 kb

My requirement is to upload camera captured image to the server, but it should be less than 500 KB. In case, if it is greater than 500 KB, it needs to be reduced to the size less than 500 KB (but somewhat closer to it) For this, I am using the…
20
votes
5 answers

broadcast receiver won't receive camera event

I'm trying to make an app that detects when a user takes a photo. I set up a broadcast receiver class and registered it in the manifest file by:
19
votes
3 answers

Camera on Android Example

I want to write an activity that: Shows the camera preview (viewfinder), and has a "capture" button. When the "capture" button is pressed, takes a picture and returns it to the calling activity (setResult() & finish()). Are there any complete…
Ralf
  • 14,655
  • 9
  • 48
  • 58
19
votes
7 answers

onActivityResult returned from a camera, Intent null

I follow the instruction on Camera on Android dev site I just start the Camera Intent, not build my own camera. The sample code to handle result return after taking a photo is as follows. protected void onActivityResult(int requestCode, int…
EyeQ Tech
  • 7,198
  • 18
  • 72
  • 126
18
votes
2 answers

Picture coming from camera or gallery?

I have an intent chooser that allows me to pick image from gallery or camera like this: Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT,null); galleryIntent.setType("image/*"); …
Hossam Oukli
  • 1,296
  • 3
  • 19
  • 42
17
votes
2 answers

set orientation of android camera started with intent ACTION_IMAGE_CAPTURE

I'm working at an application in android which uses camera to take photos.For starting the camera I'm using an intent ACTION_IMAGE_CAPTURE like this: Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File image=new…
adrian
  • 4,574
  • 17
  • 68
  • 119
17
votes
8 answers

Android: App crashes on onActivityResult while using Camera Intent

I am using camera intent to capture images in my App. The problem my app crashes on Android 5.0.2 while using camera. I am using intent from fragment. Below is my code inside fragment: Method to take photo private void takePhoto() { …
Nitish
  • 3,097
  • 13
  • 45
  • 80
1
2
3
64 65