0

I'm using the following code to open an image picker on Android.

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
fragment.startActivityForResult(Intent.createChooser(intent, "Gallery"), Constants.RetCodes.SELECT_PIC);

This opens to the "Recent" directory which NEVER contains any images. Every time I run the app, I have to open the hamburger menu in the upper left and choose "Photos", then choose "Photos" again on the screen after that in order to actually get to any pictures.

How can I force the picker to just open in "Photos|Photos" right away instead of going to "Recent", which is completely useless?

Bungles
  • 1,969
  • 2
  • 25
  • 54
  • 2
    Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto, Constants.RetCodes.SELECT_PIC); did you try it? – Công Hải May 08 '20 at 01:53
  • Thanks! I thought ACTION_PICK was deprecated or the "old" way and ACTION_GET_CONTENT is the "new" way? – Bungles May 08 '20 at 02:39
  • 1
    I have view document it not said ACTION_PICK is deprecated. only different between ACTION_PICK and ACTION_GET_CONTENT is ACTION_PICK you need specific URI from example from MediaStore.Images.Media.EXTERNAL_CONTENT_URI, and ACTION_GET_CONTENT you only specific type example image/* audio/* but it not know what exactly folder to choose – Công Hải May 08 '20 at 02:50
  • 1
    take a look here https://developer.android.com/reference/android/content/Intent#ACTION_GET_CONTENT – Công Hải May 08 '20 at 02:50

0 Answers0