我用下面的代碼來調用已有相機:警告:相機失敗
// New intent to Camera feature
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
Uri fileUri = Uri.fromFile((new File((new Date()).toString()))); // create a file to save the video
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
// start the Video Capture Intent
startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
我可以拍攝照片,但不能錄製視頻,我收到了錯誤Warning : Camera failed
我試着做一些與some solutions有關的事情,但不能收到好的結果。 (雖然重置手機)
請告訴我如何解決這個問題,
感謝,
P/S:設備 - 三星Galaxy Tab 7 2.2.1
編輯: 我用下面的代碼來接收響應,並響應結果resultCode == RESULT_CANCELED
if (resultCode == RESULT_OK) {
// Video captured and saved to fileUri specified in the Intent
Toast.makeText(this, "Video saved to:\n" +
data.getData(), Toast.LENGTH_SHORT).show();
} else if (resultCode == RESULT_CANCELED) {
// User cancelled the video capture
Toast.makeText(this, "User cancelled the video capture", Toast.LENGTH_SHORT).show();
} else {
// Video capture failed, advise user
Toast.makeText(this, "Warning : Camera failed", Toast.LENGTH_SHORT).show();
}
爲什麼你不檢查是否實際返回意圖?類似於這個http://developer.android.com/training/camera/videobasics.html也檢查這個線程http://stackoverflow.com/questions/2550743/android-video-capture-sample-app –
@Boris:我編輯代碼請按照您的評論。我也運行第二個鏈接(項目),我得到黑屏@@什麼也沒有發生。 –
你必須創建新的活動添加Surfaceholder和MediaRecorder類的句柄videorecording很容易 – Sanket990