Android 5.1: 无法捕获和获取全尺寸图像

Android 5.1: can not capture and get full-size image

我正在尝试使用此 official android tutorial

捕获并获取全尺寸图像

但是没有用,我发现mCurrentPhotoPathreturnsnullonActivityResult

我在这段代码中定义了mCurrentPhotoPath

      private File createImageFile() throws IOException {
            // Create an image file name
            String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
            String imageFileName = "JPEG_" + timeStamp + "_";
            File storageDir = Environment.getExternalStoragePublicDirectory(
                    Environment.DIRECTORY_PICTURES);
            File image = File.createTempFile(
                imageFileName,  /* prefix */
                ".jpg",         /* suffix */
                storageDir      /* directory */
            );
            // Save a file: path for use with ACTION_VIEW intents
            mCurrentPhotoPath = image.getAbsolutePath();
            return image;
        }

所以请帮我保存图片并获取图片路径。

很有可能,您的进程在后台时被终止。您需要确保在保存的实例状态 Bundle 中为您的 activity 或正在调用 startActivityForResult() 的片段保留路径。