Place the button in the xml file where you want to open the camera for recording video.
here I put the video encoding code.
this will create a folder on your SD card / or if no SD card is inserted, it will use inbult sytem memory. hope you know. I do not need to explain much about this.
, xml
Button recordButton =
(Button) findViewById(R.id.CaptureVid);
recordButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String timestamp="1";
String timestamp = new SimpleDateFormat("MM-dd-yyyy_HH-mm-ss aa").format(Calendar.getInstance().getTime());
File filepath = Environment.getExternalStorageDirectory();
File dir = new File(filepath.getAbsolutePath()+ "/samplevideofolder/");
dir.mkdirs();
File mediaFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/samplevideofolder/Video_"+timestamp+".avi");
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
Uri fileUri = Uri.fromFile(mediaFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30);
startActivityForResult(intent, VIDEO_CAPTURE);
}
});
- ,
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VIDEO_CAPTURE) {
if (resultCode == RESULT_OK) {
Toast.makeText(this, "Video saved to:\n" +data.getData(), Toast.LENGTH_LONG).show();
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Video recording cancelled.", Toast.LENGTH_LONG).show();
} else {
}
}
}
, .
.
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30);
30 ,,
, unlimietd time.. .. ok