Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid get full size image from camera
    text
    copied!<p>I am developing an Android App which uploads an image from the camera or from the device photo gallery to remote site. The latter I have working fine, I can select and upload. However, I am have trouble taking a full size image and uploading. This is my code:</p> <pre><code>// From onCreate Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); </code></pre> <p>I have a method to handle the Activity result. This both handles selecting from the gallery and from the camera:</p> <pre><code>public void onActivityResult(int requestCode, int resultCode, Intent data) { String filepath = ""; Uri selectedImageUri; if (resultCode == RESULT_OK) { if (requestCode == CAMERA_PIC_REQUEST) { Bitmap photo = (Bitmap) data.getExtras().get("data"); // Gets real path of image so it can be uploaded selectedImageUri = getImageUri(getApplicationContext(), photo); } else { selectedImageUri = data.getData(); } // Handle the upload ... } } public Uri getImageUri(Context inContext, Bitmap inImage) { String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null); return Uri.parse(path); } </code></pre> <p>This works however, the image is small and does not follow the naming convention for stored images. I have read that to save full size I need to use putExtra and pass MediaStore.EXTRA_OUTPUT on the cameraIntent and declare a temporary file, so I have adapted my intent code as follows:</p> <pre><code>Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss"); camImgFilename = sdf.format(new Date())+".jpg"; File photo = new File Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), camImgFilename); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); </code></pre> <p>This however results in an error being thrown stating "Source not found". </p> <p>Not sure where to proceed from here?</p> <p><strong>UPDATE</strong></p> <p>It appears that my photo is being created. Once the app has closed I can navigate with the file explorer to the directory and see the image. I'm unsure of what is causing the app to crash.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload