Android EXIF getAttributes返回null

Android EXIF getAttributes返回null,android,exif,Android,Exif,我正在尝试列出与库中图像相关联的所有exif属性。每个getAttribute()都返回null。当我调试和检查ExiFinInterface时,它有一个有效的文件,当我展开“mAttributes”节点时,“Table”包含我要查找的所有EXIF数据,但“values”、“keySet”和“valuescollection”为空。知道我哪里出错了吗 编辑:也许问题在于如何获取文件名?我已经更新了下面的代码,以提供更完整的图片 //create an array of thumbnail IDs

我正在尝试列出与库中图像相关联的所有exif属性。每个getAttribute()都返回null。当我调试和检查ExiFinInterface时,它有一个有效的文件,当我展开“mAttributes”节点时,“Table”包含我要查找的所有EXIF数据,但“values”、“keySet”和“valuescollection”为空。知道我哪里出错了吗

编辑:也许问题在于如何获取文件名?我已经更新了下面的代码,以提供更完整的图片

//create an array of thumbnail IDs
String[] ids = {MediaStore.Images.Thumbnails._ID};
//this pulls the file locations
cursor = managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, ids, null, null, MediaStore.Images.Thumbnails.IMAGE_ID);
colIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);

//at this point we need to target the gridview.
GridView gallery = (GridView) findViewById(R.id.gridView1);
//borrowed an adapter provided in the tutorial at http://mihaifonoage.blogspot.com/2009/09/displaying-images-from-sd-card-in.html
gallery.setAdapter(new ImageAdapter(this));

//now we attach a listener to our gridview.
gallery.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(AdapterView parent, View v, int position, long id)
    {
        String[] ids = {MediaStore.Images.Media.DATA};
        cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, ids, null, null, null);
        colIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToPosition(position);
        String image = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));
        ExifInterface clicked = null;
        try {
            clicked = new ExifInterface(image);
    } catch (IOException e) {
            // TODO Auto-generated catch block
        e.printStackTrace();
    }

        if(clicked==null)
        {
        Toast.makeText(getApplicationContext() , "We were not able to load the file." , Toast.LENGTH_LONG).show();
        }
        else
        {
        TextView tv = (TextView) findViewById(R.id.messageCenter);
        String message;
        message = "Latitude: " +  clicked.getAttribute(ExifInterface.TAG_GPS_LATITUDE)  + "\n";
        message += "Longitude: " + clicked.getAttribute(ExifInterface.TAG_GPS_LONGITUDE) + "\n";
        message += "Make: " + clicked.getAttribute(ExifInterface.TAG_MAKE) + "\n"; 
        message += "Model: " + clicked.getAttribute(ExifInterface.TAG_MODEL) + "\n";
        message += "Date/Time: " + clicked.getAttribute(ExifInterface.TAG_DATETIME) + "\n";
        message += "Flash: " + clicked.getAttribute(ExifInterface.TAG_FLASH) + "\n";
        message += "Flocal Length: " + clicked.getAttribute(ExifInterface.TAG_FOCAL_LENGTH) + "\n";
        message += "White Balance: " + clicked.getAttribute(ExifInterface.TAG_WHITE_BALANCE);

        tv.setText(message);
    }
}
});
以下是单击在运行时的外观


编辑:我发现调用表中列出的值是有效的。但是,如果展开mAttributes.table。[0].value.value,我要查找的其他信息将列在字符数组中。为什么这些信息没有被传递出去?

有些图片效果很好-所以问题是数据,而不是类或我的代码。我怀疑某些设备/应用程序以ExiFinInterface无法解析的非标准方式对其exif数据进行编码。

您必须怀疑用于编辑图像的任何软件。即使它只是一个“查看器”,您也可以使用它以不同的格式保存它。有些人会把EXIF弄坏,有些人会把它拆开。此外,即使您认为EXIF是一个标准,但制造商之间在实现和命名标签的精确程度上存在很大差异。有一个名为的工具,您不仅可以使用它来转储EXIF,还可以对其进行修改和标准化。也许你可以将其嵌入到你的流程中,或者从你的代码中调用它。

这可能不是你的问题,但这些常量不应该是
ExifInterface.TAG\u GPS\u LATITUDE
而不是
单击。TAG\u GPS\u LATITUDE
?我也试过了。我也试着使用常量的值,例如TAG_MODEL的值是“MODEL”。那里也没有骰子。是的,真的。这是谷歌安卓操作系统带来的痛苦。