Skip to content Skip to sidebar Skip to footer

Mediastore.action_video_capture Not Saving The Video In Nougat 7.0

Hi i have been trying to record and save a video from Nougat 7.0 using intent, I can record a video but its not getting saved in the device storage. I even used FileProvider to avo

Solution 1:

here is the solution !

If your targetSdkVersion is 24 or higher, we have to use FileProvider class to give access to the particular file or folder to make them accessible for other apps.

Stackoverflow link: android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData()

also you should check the required permission android.Manifest.permission.CAMERA

Solution 2:

FileVideo_folder=newFile(Environment.getExternalStorageDirectory(),
 "Sample/Videos")
File videoMediaFile=null;
    privatevoidDispatchVideoRecordIntent() {
            try {
                videoMediaFile = File.createTempFile(
                        "VID_" + System.currentTimeMillis(),
                        ".mp4",
                        Video_folder
                );
                IntenttakeVideoIntent=newIntent(MediaStore.ACTION_VIDEO_CAPTURE);
                takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(videoMediaFile));
                startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
            } catch (Exception e) {
                Log.e("Image Capturing", e.toString());
            }
        }



@OverrideprotectedvoidonActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
 if (resultCode == RESULT_OK && requestCode == REQUEST_VIDEO_CAPTURE) {
            if (!TextUtils.isEmpty(videoMediaFile.getAbsolutePath())) {
                       // videoMediaFile.getAbsolutePath() is your file path

            } else {
                Toast.makeText(this, "Unable to capture video.", Toast.LENGTH_SHORT).show();
            }
}

Post a Comment for "Mediastore.action_video_capture Not Saving The Video In Nougat 7.0"