Dear all.
Currently, Eclair 2.1 might have a problem when calculating image
taken time during media scanning.
When an image is captured in Camera, the taken time is written
correctly in media DB.
But if the device is booted, the image taken time is changed from
original taken time to the time added as timezone.
# \frameworks\base\media\java\android\media\ExifInterface.java.
public long getDateTime() {
String dateTimeString = mAttributes.get(TAG_DATETIME);
Log.e(TAG, "DATETIME " + dateTimeString);
if (dateTimeString == null) return -1;
ParsePosition pos = new ParsePosition(0);
try {
Date date = sFormatter.parse(dateTimeString+"Z", pos);
if (date == null) return -1;
Log.e(TAG, "Date = "+date + ", getTime = "+date.getTime());
return date.getTime();
} catch (IllegalArgumentException ex) {
return -1;
}
}
04-27 13:16:59.690: ERROR/ExifInterface(1531): DATETIME 2010:04:26
22:44:15
04-27 13:16:59.690: ERROR/ExifInterface(1531): Date = Tue Apr 27
07:44:15 Asia/Seoul 2010, getTime = 1272321855000
==> 9 hours is added to the original taken time.
But, if same code is used in application, the return value is
different from the value gotten from framework.
ExifInterface exif = null;
private static SimpleDateFormat sFormatter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try{
exif = new ExifInterface("/sdcard/DCIM/Camera/IMG001.JPG");
}catch(IOException ex){
}
if(exif != null){
String date = exif.getAttribute("DateTime");
sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
try {
Date dateFormat = sFormatter.parse(date, pos);
Log.e(TAG, "Date = "+dateFormat + ", time =
"+dateFormat.getTime());
} catch (IllegalArgumentException ex) {
}
}
}
04-27 11:36:32.165: ERROR/TimeZoneTest(6954): Date = 2010:04:26
22:44:15
04-27 11:36:32.175: ERROR/TimeZoneTest(6954): Date = Mon Apr 26
22:44:15 Asia/Seoul 2010, time = 1272289455000
So, if SD card is detached and attached again, the taken time is
changed as timezone time.
If anyone knows or experiences, let me know how to deal with this
case.
Thanks.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en