Android 无法在SD卡中存储摩托罗拉平板电脑中摄像头拍摄的图片

Android 无法在SD卡中存储摩托罗拉平板电脑中摄像头拍摄的图片,android,storage,tablet,motorola,android-camera-intent,Android,Storage,Tablet,Motorola,Android Camera Intent,我正在尝试从android应用程序打开摄像头并拍摄图像, 但它不存储在SD卡中。 如果我从内置摄像头捕获图像,它会将图像存储在SD卡上。 使用以下代码:(尝试打开相机) 在清单许可中: <uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-p

我正在尝试从android应用程序打开摄像头并拍摄图像, 但它不存储在SD卡中。 如果我从内置摄像头捕获图像,它会将图像存储在SD卡上。 使用以下代码:(尝试打开相机)

在清单许可中:

<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

我的代码中缺少什么吗


提前谢谢。

这对我来说很有效

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
startActivityForResult(intent, TAKE_PHOTO_CODE);
和getImageUri()

有关更多信息,请查看

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
startActivityForResult(intent, TAKE_PHOTO_CODE);
/**
 * Get the uri of the captured file
 * @return A Uri which path is the path of an image file, stored on the dcim folder
 */
private Uri getImageUri() {
    // Store image in dcim
    File file = new File(Environment.getExternalStorageDirectory() + "/DCIM", CAPTURE_TITLE);
    Uri imgUri = Uri.fromFile(file);

    return imgUri;
}