I'm working on a project on which I need to retrieve images from gallery that is captured by camera in a certain time span. Please advice a way to do this.
Thanks.
Edit:
Here is what I found,
You can make use of ExifInterface. Here is the doc.
First, retrieve images taken by camera by using this
Then get the real path of images by using this
private String getRealPathFromURI(Uri contentURI, Activity activity) {
Cursor cursor = activity.getContentResolver()
.query(contentURI, null, null, null, null);
if (cursor == null) { // Source is Dropbox or other similar local file
// path
return contentURI.getPath();
} else {
cursor.moveToFirst();
int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
return cursor.getString(idx);
}
}
Now use this to get the time the image captures using the following code
String currentImageFile = Utility.getRealPathFromURI(flyerUri, getActivity());
ExifInterface ei = null;
try {
ei = new ExifInterface(currentImageFile);
if(ei != null)
{
Log.e("","---> date and time "+ei.getAttribute(ExifInterface.TAG_DATETIME));
}
} catch (IOException e) {
e.printStackTrace();
}
Now you have the images captured by camera and time the picture was taken. Use it according to your requirement. :)