I am trying to save Video file on SD card but getting null pointer. Have a look of my code.
I just need to create a folder in SD Card and save videos on it. When i have not using fileUri then not got Crash.
File mediaFile = new
File(Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/myvideo"+System.currentTimeMillis() +".mp4");
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
fileUri = Uri.fromFile(mediaFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(intent, VIDEO_CAPTURE);
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VIDEO_CAPTURE) {
if (resultCode == Activity.RESULT_OK) {
Toast.makeText(getActivity(), "Video has been saved to:\n" +
data.getData(), Toast.LENGTH_LONG).show();
} else if (resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(getActivity(), "Video recording cancelled.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getActivity(), "Failed to record video",
Toast.LENGTH_LONG).show();
}
}
}
Thanks. Suggestion appreciated.
Try this,
Refer this link,
http://androidexample.com/Camera_Video_Capture_And_Save_On_SDCard_-_Android_Example/index.php?view=article_discription&aid=123
I wish it will help you.