我米使用攝像頭活動使用意圖在Intent MediaStore中使用Camera活動。 INTENT_ACTION_STILL_IMAGE_CAMERA數據返回空
MediaStore. INTENT_ACTION_STILL_IMAGE_CAMERA with startactivityforresult
但我採取了PIC或視頻後,按返回鍵,我得到發送resultCode = 0和數據= NULL。
任何幫助將不勝感激。
我米使用攝像頭活動使用意圖在Intent MediaStore中使用Camera活動。 INTENT_ACTION_STILL_IMAGE_CAMERA數據返回空
MediaStore. INTENT_ACTION_STILL_IMAGE_CAMERA with startactivityforresult
但我採取了PIC或視頻後,按返回鍵,我得到發送resultCode = 0和數據= NULL。
任何幫助將不勝感激。
DIdü嘗試使用MediaStore.ACTION_IMAGE_CAPTURE來代替?它適用於我。我能夠拍攝照片並獲得URI。下面是代碼
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
String fileName = TravellerUtils.generateUniqueID()
+ IMAGE_FILE_EXT;
File file = new File(Environment.getExternalStorageDirectory(),
TravellerConstants.IMAGE_PATH + fileName);
Uri outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
這個意圖MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA可以拍攝幾張照片並將其發送到庫,但是,你不能抓住它拍照之後。它也可以讓你拍攝視頻,但你也無法捕捉。
我建議你分別用兩個意圖拍照和錄像。
;畫面:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "Camera");
imagesFolder.mkdirs();
Random random = new Random();
int n = random.nextInt(10000);
File image = new File(imagesFolder, "YourApplication" + n + ".jpg");
photoUri = Uri.fromFile(image);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); // set the image file name
// start the image capture Intent
startActivityForResult(intent, Constants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
和視頻:
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO); // 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);