2

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. :)

Community
  • 1
  • 1
Manu
  • 379
  • 2
  • 16
  • by trying something... post some code implementation so far, show some effort... we can't make your homework or give you samples – Mariano Zorrilla Oct 14 '15 at 14:10
  • May I know why it is voted negative. SO that I can improve my question. – Manu Oct 14 '15 at 14:11
  • @MarianoZorrilla just want to know whether it is possible to do. At least you can guide, I'm not looking for you to do this for me. I just want to start with a right method. – Manu Oct 14 '15 at 14:12
  • @MarianoZorrilla If you don't know the answer, please don't attend the post. .simple. – Rakki s Oct 14 '15 at 14:16
  • @Manu the reason you are being down voted and why this question will likely end up getting closed, is you aren't asking a specific question about a problem with _your_ code. You are asking an implementation or "how-to" question. Questions of that nature are considered off-topic: http://stackoverflow.com/help/on-topic – Chris Stillwell Oct 14 '15 at 14:23
  • 1
    Have a look at [this](http://stackoverflow.com/a/4495753/4791726). – AlbAtNf Oct 14 '15 at 14:23
  • Thanks. .that was helpful. – Manu Oct 14 '15 at 14:24
  • 1
    @Rakkis the question is lacking of everything. If you read the on-topic, how to ask, etc you would see. BTW, you comment is also pointless. The idea to post some code is to help him to make it possible... but not the entire thing from scratch. Is too broad. – Mariano Zorrilla Oct 14 '15 at 14:24
  • 1
    @MarianoZorrilla Now you can see how a question can be a useful stuff :) – Manu Oct 14 '15 at 15:10

0 Answers0