в вашем методе onCreate укажите следующие строки,
String imgName = getImageName();
startCamera(imgName);
И ниже вашего onCreate укажите эти методы.ваша камера готова.
private void startCamera(String ImageName) {
Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
Uri.fromFile(new File(ImageName)));
startActivityForResult(cameraIntent, TAKE_PICTURE_WITH_CAMERA);
}
private String getImageName() {
String imgname = "";
String imgpath = "";
String strDirectory="/sdcard";
try {
imgname = String.format("%d.mp4", System.currentTimeMillis());
imgpath = strDirectoy + "/" + imgname;
File file = new File(strDirectoy);
boolean exists = file.exists();
if (!exists) {
boolean success = (new File(strDirectoy)).mkdir();
if (success)
Log.e("Directory Creation", "Directory: " + strDirectoy
+ " created");
else
Log.e("Directory Creation", "Error in Create Directory");
}
Log.i("Imagename : ", imgpath);
} catch (Exception e) {
Log.e("fileException", e.getMessage());
e.printStackTrace();
}
return imgpath;
}