Inactive path to Android capture file not working

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)

// makes new unique filenames like Picture_03161185528.jpg
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)

// makes new unique filenames like Video_03161185528.3gp        
fileName = makeFileName("Video")+".3gp";
// even tried this hardwired filename...but nothing
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);
// seems to be ignored, the file always get saved under default filename
intent.putExtra("output", outputFileUri);      
// same as previous line...seems to be ignored
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

+3
source share
1 answer

, uri . uri, , .

ContentValues values = new ContentValues();  
values.put(MediaStore.Video.Media.TITLE, "video name");                                 
values.put(MediaStore.Images.Media.DATE_TAKEN,System.currentTimeMillis());                  
//videoUri = mediastore path    
videoUri = CaptureContentFragment.this.getActivity().getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);                  
//create new Intent                     
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); 
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 20);
CaptureContentFragment.this.getActivity().startActivityForResult(intent, TabsActivity.VIDEO_REQUEST_CODE);
0

All Articles