Android Dev有一些简单的代码来描述如何通过Intents启动摄像机。Android - 如何在调用摄像机意图时自动录制视频
现在,如果您只是想启动相机并等待用户按下红色的“REC”按钮,那么这很好。
但我想通过Intent调用摄像机,并告诉它以编程方式开始录制。
我该怎么做? 我是否在Intent命令中传递某种start()方法?
(如果它不能这样做,请告诉我,可以设置为自动录制视频一个简单的代码位 - 我一直在寻找的网站,但关于这个问题的所有codesnippets不工作)
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类,并通过它们在开发指南中提供的代码示例。但是代码示例缺乏精确性。很难弄清楚如何使用代码。 – user1020196