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