读取 EXIF 信息
我试图从 SD 卡读取所有媒体文件并获取第一个文件的 EXIF 数据,但它不起作用。代码是:
String[] proj = { MediaStore.Images.Media.DATA };
Cursor c = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
null, null, null);
String imagePath = "";
if(c!= null && c.moveToFirst()){
imagePath = c.getString(c.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));
if (!c.isClosed()) {
c.close();
}
}
if(!imagePath.equals("")){
ExifInterface exif = new ExifInterface(imagePath);
String updated = exif.getAttribute(ExifInterface.TAG_DATETIME);
system.print.out("Photo updated at:"+updated);
}
sysout 正在打印“null”。
I am trying to read the all the media files from the SD card and get the EXIF data for the first file but it's not working. The code is:
String[] proj = { MediaStore.Images.Media.DATA };
Cursor c = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
null, null, null);
String imagePath = "";
if(c!= null && c.moveToFirst()){
imagePath = c.getString(c.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));
if (!c.isClosed()) {
c.close();
}
}
if(!imagePath.equals("")){
ExifInterface exif = new ExifInterface(imagePath);
String updated = exif.getAttribute(ExifInterface.TAG_DATETIME);
system.print.out("Photo updated at:"+updated);
}
The sysout is printing "null".
您只能获取扩展名为 .jpeg 的图像文件的 exif 信息,甚至无法获取扩展名为 .jpg 的图像文件的 exif 信息。
you can only get exif information for image file with .jpeg extension even not for .jpg extension.