I work in an application that should launch a camera application using intentions; the camera starts in image or video mode, and while it is working and saves the received file in the SD card. Now the problem is that although the specification of the new custom file name works for the intent of the image, it does not seem to work for the intent of the camcorder; in fact, EXTRA_OUTPUT or just “output” seems to be ignored in the intent of the video. I use the following codes:
For photographs (all works are asked, including saving a picture with a custom file name)
fileName = makeFileName("Picture")+".jpg";
path = (new StringBuilder()).
append(Environment.getExternalStorageDirectory()).
append("/"+fileName).toString();
File file = new File(path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("output", outputFileUri);
mainActivity.startActivityForResult(intent, CAMERA_RESULT);
For video (video is required, but always use the default name such as VIDEO001, VIDEO002, etc., not the custom filename I need)
fileName = makeFileName("Video")+".3gp";
fileName = "video.3gp";
path = (new StringBuilder()).
append(Environment.getExternalStorageDirectory()).
append("/"+fileName).toString();
File file = new File(path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra("output", outputFileUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
mainActivity.startActivityForResult(intent, VIDEO_RESULT);
In any case, the image intent saves images with my custom file names, but the video intent explicitly ignores it and always saves files using the default file names. My question is:
a) Is there a way to do this using custom file names? b) or, alternatively, is there a way to find out the next available default file name forehand? c) or is there another way to find out which file was created and then rename it?
Greetings and thanks!
Aram
source
share