Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is how I manage with saving images to specified imagefolder</p> <p>When starting camera intent I define path and directory, where my image should be saved, and pass this as intetn extra when starting camera:</p> <pre><code> private void startCameraIntent() { //create file path final String photoStorePath = getProductPhotoDirectory().getAbsolutePath(); //create file uri final Uri fileUri = getPhotoFileUri(photoStorePath); //create camera intent final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //put file ure to intetn - this will tell camera where to save file with image cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // start activity startActivityForResult(cameraIntent, REQUEST_CODE_PHOTO_FROM_CAMERA); //start image scanne to add photo to gallery addProductPhotoToGallery(fileUri); } </code></pre> <p>And here are some of helper methods used in code above</p> <pre><code> private File getProductPhotoDirectory() { //get directory where file should be stored return new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES), "myPhotoDir"); } private Uri getPhotoFileUri(final String photoStorePath) { //timestamp used in file name final String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); // file uri with timestamp final Uri fileUri = Uri.fromFile(new java.io.File(photoStorePath + java.io.File.separator + "IMG_" + timestamp + ".jpg")); return fileUri; } private void addProductPhotoToGallery(Uri photoUri) { //create media scanner intetnt Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); //set uri to scan mediaScanIntent.setData(photoUri); //start media scanner to discover new photo and display it in gallery this.sendBroadcast(mediaScanIntent); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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