Search code examples
androidandroid-cameravideo-capture

How Can I record a short video in an Android app?


I am developing an application where I press a button and it will record a 10 second video and store it in internal storage. How can I do that?


Solution

  • Using Intent you can do this.

    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takeVideoIntent, CAMERA_REQUEST_CODE_VEDIO);
    }
    

    in onActivityResult method

    Uri videoUri = data.getData();
    path = Utils.getRealPathFromURI(videoUri, this);
    manageVideo(path); //Do whatever you want with your video