Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9054517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:42:35+00:00 2026-06-16T13:42:35+00:00

I want to record a video from my Android application. like this File f

  • 0

I want to record a video from my Android application.
like this

File f = new File(Environment.getExternalStorageDirectory() + "/"
            + app.getBaseName());
    if (!f.exists()) {
        f.mkdir();
    }



    filename = "Video" + lastfile() + ".mp4";

    File f1 = new File(Environment.getExternalStorageDirectory() + "/"
            + app.getBaseName(), filename);

    Uri uri = Uri.fromFile(f1);

    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
    startActivityForResult(intent, 222);

and in Activity on result

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == 222) {
        Log.v("log_tag", "Return to back 222" + resultCode);
        if (resultCode == RESULT_OK) {
            Log.v("log_tag", "Return to back");


        } else if (resultCode == RESULT_CANCELED) {
            // User cancelled the image capture
        } else {
            // Image capture failed, advise user
        }

        Log.v("log_tag", "Return to back fury");
    }

    finish();
    super.onActivityResult(requestCode, resultCode, data);
}

using this, camera is starting then I clicked middle button for recording start than I clicked left side button to stop and save and application crashed.

I printed value of resultCode in onActivityResult which gave me 0.
and video was saved on my given path with given name properly.
please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:42:37+00:00Added an answer on June 16, 2026 at 1:42 pm

    I could not found proper solution for this but I solved my problem using this flow. let save video file anywhere by default and make another copy where you want, you can also delete original file after copy.

    like this

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     if (requestCode == 222) {
      if (resultCode == RESULT_OK){   
       try {
         AssetFileDescriptor videoAsset = getContentResolver().openAssetFileDescriptor(data.getData(), "r");
         FileInputStream fis = videoAsset.createInputStream();
         File f1 = new File(Environment.getExternalStorageDirectory() + "/" + app.getBaseName(), filename);
         FileOutputStream fos = new FileOutputStream(f1);
    
         byte[] buffer = new byte[1024];
         int length;
         while ((length = fis.read(buffer)) > 0) {
               fos.write(buffer, 0, length);
         }       
         fis.close();
         fos.close();
       } catch (IOException e) {
          // TODO: handle error
       }
      }
     }
    super.onActivityResult(requestCode, resultCode, intent);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created an application for android. Now, I want to record a video on
We want to build an application that allows the user to record a video
I want to make an app which takes a video from the camera, adds
I want to give my users the ability to record a video from WebCam
I want to record video only in android with MPEG4 format. I want the
i want to record video through webcam using Directshow.Net.i can able to record the
I want to access camera to record video to upload, but have come across
I want to record the handshake messages between server and client into the file
i want to record my app in ipad is there any esay way to
I am developing an application in which I want to record the sound of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.