Android - How to start recording video automatically when you call the camera

Android Dev has a simple code that describes how to launch the camcorder using intent.

Now itโ€™s good if you just want to start the camera and wait for the user to press the red โ€œRECโ€ button.

But I want to call the camcorder through Intent and tell her to start recording programmatically.

How to do it? Am I passing some kind of start () method on an Intent command?

(if this cannot be done, please show me a simple bit of code that can be configured to record video automatically - I searched the Internet, but all codes regarding this problem do not work)

private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
private Uri fileUri;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// create Intent to take a picture and return control to the calling application
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
+5
source share
2 answers
+1

. Intent ( startActivity(), not startActivityForResult()). -, key code "input keyevent 27". ! . , ( 4) .

:

  • CAMERA: ( ). ,
  • DPAD_DOWN, DPAD_RIGHT , , DPAD_CENTER !
  • BACK, .
0

All Articles