4

I want to show to the user his latest photos or screenshot made by him in my app.

                    String[] projection = new String[]{
                        MediaStore.Images.ImageColumns._ID,
                        MediaStore.Images.ImageColumns.DATA,
                        MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
                        MediaStore.Images.ImageColumns.DATE_TAKEN,
                        MediaStore.Images.ImageColumns.MIME_TYPE
                };
                final Cursor cursor = getActivity().getContentResolver()
                        .query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null,
                                null, MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC");

In order to get the latest photos on the phone i use Cursor.

How can i check if the picture/screenshot was taken on this phone?

I don't want unrelated WhatsApp photos (or other apps) to be shown, only photos from camera roll and screenshots.

Montoya
  • 2,819
  • 3
  • 37
  • 65

1 Answers1

4

I think this post https://stackoverflow.com/a/4495753/2014374 should help you finding your answer.

It used content resolver over Images.Media.EXTERNAL_CONTENT_URI and filters the results by getting the Media.BUCKET_ID from media bucket name "/DCIM/Camera"; Hope this helps.

Community
  • 1
  • 1
bpr10
  • 1,086
  • 8
  • 14
  • Not all android devices still have same BUCKET_ID or directory where they save photos. Unfortunately, I do not yet know, how to get BUCKET_NAME for all camera apps – user2576168 Nov 22 '17 at 16:31