Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Camera no save in specific folder [MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA]

I'm a problem when I using the MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA in the Intent. The camera starts correctly but it doesn't save the files in my specific folder "/photo". But when I use the MediaStore.ACTION_IMAGE_CAPTURE it works fine, but I can't use this because it take only one photo each time. I need the camera starts and the user takes many photos. After he closes the camera and all photos are saved in my specific folder.

Thanks for your help.

Regards,

Marcelo

Source code:

public void startCamera() {     
    Intent takePictureIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
    File file = null;
    try {
        file = createImageFile();
        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
    } catch (IOException e) {
        file = null;
        Log.e(this.getClass().getName(), e.getMessage(), e);            
    }
    activity.startActivity(takePictureIntent);
}


private File createImageFile() throws IOException {
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = JPEG_FILE_PREFIX + timeStamp + JPEG_FILE_SUFFIX;
    return new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/photo/", imageFileName);
}
like image 312
user1523903 Avatar asked Feb 19 '23 18:02

user1523903


1 Answers

MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA This intent does not support activity results or specific intent file outputs. This intent is designed to simply open the camera. The functionality you seek does not exist natively in Android.

like image 127
Jack Satriano Avatar answered Feb 22 '23 07:02

Jack Satriano