갤러리의 이미지와 관련된 모든 exif 속성을 나열하려고합니다. 모든 getAttribute()는 null을 반환합니다. 내가 디버그하고 ExifInterface를 검사 할 때 그것은 유효한 파일을 가지고 있으며 "mAttributes"노드를 확장하면 "테이블"에 내가 찾고있는 EXIF 데이터가 모두 들어 있지만 "값", "keySet"및 "valuescollection "는 null입니다. 내가 잘못 가고있는 어떤 생각?EXIF getAttributes return null
편집 : 아마도 파일 이름을 얻는 방법에 문제가있을 것입니다. 좀 더 완벽한 그림을 제공하기 위해 아래 코드를 업데이트했습니다.
//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를 확장하면 찾고있는 다른 정보가 char 배열에 나열됩니다. 그 정보가 왜 전달되지 않는가?
이것은 아마도 문제가 아니지만 그 상수는'clicked.TAG_GPS_LATITUDE' 대신'ExifInterface.TAG_GPS_LATITUDE'가되어서는 안됩니까? – kcoppock
나는 그것을 또한 시도했다. 또한 상수의 값을 사용하여 시도 했으므로 TAG_MODEL의 값은 "모델"입니다. 거기에 주사위도 없습니다. – Billdr