Android Dev 有一些简单的代码描述了如何通过 Intents 启动摄像机。
现在,如果您只想启动相机并等待用户按下红色的“REC”按钮,这很好。
但我想通过 Intent 调用摄像机并告诉它以编程方式开始录制。
我该怎么做? 我是否在 Intent 命令中传递了某种 start() 方法?
(如果做不到,请给我一个简单的代码位,可以设置为自动录制视频 - 我一直在网上搜索,但是关于这个问题的所有代码 fragment 都不起作用)
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);
}
最佳答案
为此你应该使用 MediaRecorder
类。
请看这个:
http://developer.android.com/reference/android/media/MediaRecorder.html
关于Android - 如何在调用相机 Intent 时自动开始录制视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7953138/