如何在Android中的应用程序中更改图像日期?

时间:2015-10-16 16:47:26

标签: android

如何按日期和日期更改书写的图像,以便图像更改为日期之后的第二天

2 个答案:

答案 0 :(得分:0)

如果我理解了您的问题,这种方法可能会对您有所帮助:

Dispatcher.BeginInvoke(new System.Threading.ThreadStart(delegate
{
     NavigationService.Navigate(new Uri("TmpMsg.xaml", UriKind.RelativeOrAbsolute)); 
}));

答案 1 :(得分:0)

如果你在谈论JPEG照片,也许这会有所帮助。这会更改图像的元数据:

import android.media.ExifInterface;
import java.util.*;

....

ExifInterface exif = new ExifInterface(filename);
String date = exif.getAttribute(ExifInterface.TAG_DATETIME); //or TAG_DATETIME_DIGITIZED or TAG_GPS_DATESTAMP or TAG_GPS_TIMESTAMP
if(date == null) //do something;

进行必要的处理以确定该日期是什么。然后,保持字符串的格式,更改它以反映第二天。增加一天的一种方法是

GregorianCalendar c = new GregorianCalendar(year,month,day);
c.add(Calendar.DATE,1);
int updatedYear = c.get(Calendar.YEAR);
int updatedMonth = c.get(Calendar.MONTH);
int updatedDay = c.get(Calendar.DATE);

然后使用以下命令更新文件:

exif.setAttribute(ExifInterface.TAG_DATETIME, updatedDate); //use whichever TAG_ you used in the first part
exif.saveAttributes();