Using Content URI with ACTION_VIDEO_CAPTURE

I am currently using the Content URI for a file provider to retrieve camera images returned by intent ACTION_IMAGE_CAPTURE. It works great.

For some strange reason, the same call does not work when trying to get a video file from the camera.

        destinationFile = File.createTempFile("video", ".mp4", this.getFilesDir());
        Uri uri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", destinationFile);

        Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        cameraIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
        cameraIntent.setClipData(ClipData.newRawUri(null, uri));
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        startActivityForResult(cameraIntent, ID);

When the target returns to onActivityResult(), destinationFile is empty.

Just replacing MediaStore.ACTION_VIDEO_CAPTUREwith MediaStore.ACTION_IMAGE_CAPTUREgives me the expected behavior: the captured image is saved in destinationFile.

This happens in the Android 6.0.1 warehouse on the Nexus device and the default Google app.

Are content URIs really unsupported for video capture? I would prefer not to use the file URI in the public directory.

+4
1

: Google Android.

Google, Android N, , content Uri ( targetSdkVersion N ). .

, , content Uri. , Android N, file, , file content , .

+3

All Articles