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 8195169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:02:36+00:00 2026-06-07T05:02:36+00:00

I have created an app like this. It has a Button , on the

  • 0

I have created an app like this.
It has a Button , on the click of button the video capture starts.

now I have a code like this for it:-

public class VideoCaptureComponentActivity extends Activity implements View.OnClickListener {
    VideoView vv;
    ImageButton ib;
    TextView tv;
    Intent i;
    final static int cameraData=0;
    File path = null;
    Uri myVideo;

    private static final int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 200;
    private Uri fileUri;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main);

        vv= (VideoView) findViewById(R.id.vvVideoCapture);
        ib=(ImageButton) findViewById(R.id.btnVideo);
        ib.setOnClickListener(this);
        tv= (TextView) findViewById(R.id.tvFilePath);
    }

    @Override
    public void onClick(View v) {               
        switch(v.getId())
        {
            case R.id.btnVideo:
                Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                fileUri = getOutputMediaFileUri();  // create a file to save the video
                intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);  // set the image file name
                intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // set the video image quality to high

                // start the Video Capture Intent
                startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
                break;
        }

    }

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
     if (requestCode == CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) 
     {
            if (resultCode == RESULT_OK) 
            {
                myVideo= data.getData();
                tv.setText(myVideo.toString());
                vv.setVideoURI(myVideo);
                vv.setMediaController(new MediaController(this));
                vv.requestFocus();
                vv.start(); 
            }           
    }
}


/** Create a file Uri for saving an image or video */
private static Uri getOutputMediaFileUri()
{
      return Uri.fromFile(getOutputMediaFile());
}

/** Create a File for saving an image or video */
private static File getOutputMediaFile()
{
    File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES), "MyCameraApp");

    if (! mediaStorageDir.exists()){
        if (! mediaStorageDir.mkdirs()){
            Log.d("MyCameraApp", "failed to create directory");
            return null;
        }
    }
    File mediaFile;
    mediaFile = new File(mediaStorageDir.getPath() + File.separator +
        "VID_CAPTURED" + ".mp4");
   return mediaFile;
}


}

now after I m capturing the video the application is crashing.

07-06 17:12:09.447: E/AndroidRuntime(2917): FATAL EXCEPTION: main
07-06 17:12:09.447: E/AndroidRuntime(2917): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=200, result=-1, data=Intent {  }} to activity {com.optimus.mobile.survey/com.optimus.mobile.survey.VideoCaptureComponentActivity}: java.lang.NullPointerException
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3712)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3754)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.app.ActivityThread.access$2800(ActivityThread.java:135)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2162)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.os.Looper.loop(Looper.java:143)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.app.ActivityThread.main(ActivityThread.java:4914)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at java.lang.reflect.Method.invokeNative(Native Method)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at java.lang.reflect.Method.invoke(Method.java:521)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at dalvik.system.NativeStart.main(Native Method)
07-06 17:12:09.447: E/AndroidRuntime(2917): Caused by: java.lang.NullPointerException
07-06 17:12:09.447: E/AndroidRuntime(2917):     at com.optimus.mobile.survey.VideoCaptureComponentActivity.onActivityResult(VideoCaptureComponentActivity.java:82)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.app.Activity.dispatchActivityResult(Activity.java:3931)
07-06 17:12:09.447: E/AndroidRuntime(2917):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3708)
07-06 17:12:09.447: E/AndroidRuntime(2917):     ... 11 more

basically the problem is that that
in the code

Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
fileUri = getOutputMediaFileUri();  
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);  
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); 

here it is not saving the file to location set , I dont know whats the problem .
I took this code from this link http://developer.android.com/guide/topics/media/camera.html

  • 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-07T05:02:40+00:00Added an answer on June 7, 2026 at 5:02 am

    No if you are passing Uri for saving Image or Video with putExtra(MediaStore.EXTRA_OUTPUT, fileUri); then you always receive data.getData(); in onActivityResult as NULL. so use Uri of image or Video passed with intent as:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
         if (requestCode == CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) 
         {
                if (resultCode == RESULT_OK) 
                {
                  //  myVideo= data.getData();
                    tv.setText("Video"); 
                    vv.setVideoURI(fileUri);//set Uri here which you passed with Intent
                    vv.setMediaController(new MediaController(this));
                    vv.requestFocus();
                    vv.start(); 
                }           
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this. I click on button and it works only few
I have created a datastore on the google app engine but would like to
I have created an app to standardize user creation for our AD domain. Now
I have created a startcam from my app.. and this is how the cam
Im quite new at this .....sorry in advance. I have created an app in
I have an iPhone app and would like to create iPad version of it.
I have created the app with forge, and have added in the chrome extension,
I have created an app in C# .Net 2.0 that uses the AxShockwaveFlash object
I have created an App Widget for Android 1.5. It uses a TextView to
I have created an app which allows users to buy non-consumable content. The retrieving-ids-payment-process

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.