Android – Taking photos and saving them with a custom name to a custom destination via Intent

Here’s the code that made it work: //camera stuff Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); String timeStamp = new SimpleDateFormat(“yyyyMMdd_HHmmss”).format(new Date()); //folder stuff File imagesFolder = new File(Environment.getExternalStorageDirectory(), “MyImages”); imagesFolder.mkdirs(); File image = new File(imagesFolder, “QR_” + timeStamp + “.png”); Uri uriSavedImage = Uri.fromFile(image); imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage); startActivityForResult(imageIntent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); It opens the camera and takes exactly one … Read more

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=0, data=null} to activity

Adding this first conditional should work: protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(resultCode != RESULT_CANCELED){ if (requestCode == CAMERA_REQUEST) { Bitmap photo = (Bitmap) data.getExtras().get(“data”); imageView.setImageBitmap(photo); } } }

broadcast receiver won’t receive camera event

I solved this but by using a different method. Instead of using a broadcast receiver I set up a fileobserver on separate folders that the camera saved to. It’s not as practical as the other way, but it still works fine. Here’s how I set it up: FileObserver observer = new FileObserver(android.os.Environment.getExternalStorageDirectory().toString() + “/DCIM/100MEDIA”) { … Read more

Intent does not set the camera parameters

Unfortunately, when using the camera with Intent, the only extra parameter you can set is MediaStore.EXTRA_OUTPUT Eg fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name Which allows you to map where the Camera application will store the image. Camera Facing intent extra can sometimes … Read more

Android Camera Intent Saving Image Landscape When Taken Portrait [duplicate]

The picture is always taken in the orientation the camera is built into the device. To get your image rotated correctly you’ll have to read the orientation information that is stored into the picture (EXIF meta data). There it is stored how the device was oriented, when the image was taken. Here is some code … Read more

Getting path of captured image in Android using camera intent

Try like this Pass Camera Intent like below Intent intent = new Intent(this); startActivityForResult(intent, REQ_CAMERA_IMAGE); And after capturing image Write an OnActivityResult as below protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { Bitmap photo = (Bitmap) data.getExtras().get(“data”); imageView.setImageBitmap(photo); knop.setVisibility(Button.VISIBLE); // CALL THIS METHOD TO GET … Read more

Android M Camera Intent + permission bug?

I had the same issue and find this doc from google: https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE “Note: if you app targets M and above and declares as using the CAMERA permission which is not granted, then atempting to use this action will result in a SecurityException.” This is really weird. Don’t make sense at all. The app declares Camera … Read more