【发布时间】:2013-12-28 21:18:59
【问题描述】:
我正在尝试使用 android 原生相机捕获图像,保存图像很好但不包含通常的 EXIF 数据(gps 标签、方向...)
我需要做什么才能同时保存 EXIF?
@Override
public void onClick(View v) {
Intent takePictureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
}
// Continue only if the File was successfully created
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photoFile));
imageuri = Uri.fromFile(photoFile);
startActivityForResult(takePictureIntent, CAMERA_PIC_REQUEST);
}
}
/*Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);*/
}
}
@SuppressLint("SimpleDateFormat")
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 = "file:" + image.getAbsolutePath();
return image;
}
【问题讨论】:
-
我刚刚发现了一些奇怪的东西,在我(手动)复制(手动)DICM/Camera 文件夹中的图像后,可以显示所有 exif 数据,但不能显示原始数据
-
在哪里复制图像并不重要,只要复制,一切都很好,很奇怪......
-
这意味着,MediaScanner 不会解析图像。见stackoverflow.com/questions/2170214/…
-
天才,非常感谢,爱你……大声笑.. 最佳答案 - sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory( ))));
标签: java android camera metadata android-camera-intent