我目前正在尝试将从手机拍摄的图像保存到其相册中,但是如果我在选择器对话框弹出时选择其他摄像头应用程序(例如 Google 相机),则下面的代码仅在选择股票相机应用程序时才起作用。拍摄的照片无论如何都不会被保存。
更奇怪的是,有时候图片确实会出现在相册中指定的目录中,但经过15分钟或更长时间后,使用股票相机应用程序也是如此:图片将被保存在默认相机拍摄目录中,但需要一段时间才能在指定的目录中显示出来,如果完全显示出来的话。
// Capturing Camera Image will launch camera app request image capture
void captureImage() {
//file uri to store image.
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
// Request camera app to capture image
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
// start the image capture Intent
getActivity().startActivityForResult(captureIntent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
}