public static void writeFile (File photo, double latitude, double longitude) throws IOException{
ExifInterface exif = null;
try{
Log.v("latiDouble", ""+latitude);
Log.v("longiDouble", ""+longitude);
exif = new ExifInterface(photo.getCanonicalPath());
if (exif != null) {
double latitu = latitude;
double longitu = longitude;
double alat = Math.abs(latitu);
double along = Math.abs(longitu);
String stringLati = convertDoubleIntoDegree(alat);
String stringLongi = convertDoubleIntoDegree(along);
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, stringLati);
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, stringLongi);
Log.v("latiString", ""+ stringLati);
Log.v("longiString", ""+ stringLongi);
exif.saveAttributes();
String lati = exif.getAttribute (ExifInterface.TAG_GPS_LATITUDE);
String longi = exif.getAttribute (ExifInterface.TAG_GPS_LONGITUDE);
Log.v("latiResult", ""+ lati);
Log.v("longiResult", ""+ longi);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
tôi sao chép câu trả lời từ here
Nguồn
2014-11-09 19:04:51
ExifInterface có thể hơi đáng tin cậy - Tôi đã nhìn thấy nó dữ liệu EXIF tham nhũng trong những hoàn cảnh nhất định. Một tùy chọn đáng tin cậy hơn xử lý nhiều thẻ EXIF hơn (bao gồm thẻ EXIF tùy chỉnh) là Sanselan Android. http://code.google.com/p/sanselanandroid/ Mẫu sử dụng cho Sanselan Android có tại đây: http://massapi.com/source/sanselan-0.97-incubator/src/test/java/org/apache/sanselan/ sampleUsage/WriteExifMetadataExample.java.html – Theo
Kiểm tra [this] (https://github.com/dragon66/pixymeta-android) – dragon66