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

Make sure you have both Camera Permission and READ/WRITE External Storage Permissions. Try this is working like charm with me private String selectedImagePath = “”; final private int PICK_IMAGE = 1; final private int CAPTURE_IMAGE = 2; public Uri setImageUri() { // Store image in dcim File file = new File(Environment.getExternalStorageDirectory() + “/DCIM/”, “image” + … Read more

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

Here was the final product in case anyone is still visiting this thread: public class CameraCapture extends Activity { protected boolean _taken = true; File sdImageMainDirectory; protected static final String PHOTO_TAKEN = “photo_taken”; @Override public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); File root = new File(Environment .getExternalStorageDirectory() + File.separator + “myDir” + File.separator); root.mkdirs(); … Read more

Activity killed / onCreate called after taking picture via intent

Actually the camera causes the orientation change in your activity that is why your activity is being destroyed and recreated. Add this in your manifest file it will prevent the orientation change and your activity will not get destroyed and recreated. <activity android:name=”.YourActivity” android:configChanges=”orientation|keyboardHidden|screenSize” android:screenOrientation=”portrait” > </activity>

Android 11 (R) return empty list when querying intent for ACTION_IMAGE_CAPTURE

Android 11 changes how apps can query and interact with other apps. From the docs: The PackageManager methods that return results about other apps, such as queryIntentActivities(), are filtered based on the calling app’s <queries> declaration. So you need to declare <queries> in your AndroidManifest.xml: <manifest package=”com.example”> <queries> <intent> <action android:name=”android.media.action.IMAGE_CAPTURE” /> </intent> </queries> … … Read more

android camera: onActivityResult() intent is null if it had extras

It happens the same to me, if you are providing MediaStore.EXTRA_OUTPUT, then the intent is null, but you will have the photo in the file you provided (Uri.fromFile(f)). If you don’t specify MediaStore.EXTRA_OUTPUT then you will have an intent which contains the uri from the file where the camera has saved the photo. Don’t know … 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

How to compress image size?

You can create bitmap with captured image as below: Bitmap bitmap = Bitmap.createScaledBitmap(capturedImage, width, height, true); Here you can specify width and height of the bitmap that you want to set to your ImageView. The height and width you can set according to the screen dpi of the device also, by reading the screen dpi … Read more

Low picture/image quality when capture from camera

I have used the following code and this works perfectly fine for me. values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, “New Picture”); values.put(MediaStore.Images.Media.DESCRIPTION, “From your Camera”); imageUri = getContentResolver().insert( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, PICTURE_RESULT); and also protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PICTURE_RESULT: if … Read more

Android: Activity getting Destroyed after calling Camera Intent

I have found a solution in this SO post. The issue is that when you click on the “save” button of the camera, the activity call changes the orientation method and it will be destroyed and recreated. Try to set: android:configChanges=”orientation|screenSize” in the android manifest (not only android:configChanges=”orientation” as suggested in this other SO post; … 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 exhibited by the following code copied from the Stack Overflow answer Get file path of image on Android — protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_REQUEST … Read more