我正在尝试使用此 official android tutorial 捕获并获取全尺寸图像
但是没有用,我发现mCurrentPhotoPath
在onActivityResult
中返回了null
我在这段代码中定义了 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
中为调用 startActivityForResult()
的 Activity 或 fragment 保持路径。
关于java - 安卓 5.1 : can not capture and get full-size image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31916879/