16

I'm using the built in Android image picker as follows:

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
m_activity.startActivityForResult(photoPickerIntent, PHOTO_PICKER_ID);

Is there any way to restrict this to show only locally available files. On my device it is currently picking up Picasa thumbnails and I'd like to exclude all images that are not actually present on the device.

JamieH
  • 4,788
  • 6
  • 28
  • 29

2 Answers2

49

Adding intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); will allow for local files only. It will exclude picasa images. Hope this helps.

    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
    startActivityForResult(Intent.createChooser(intent,
            "Complete action using"), PHOTO_PICKER_ID);
DevDreed
  • 618
  • 6
  • 6
  • 7
    The only problem with the `EXTRA_LOCAL_ONLY`flag is it's [only available since Honeycomb](http://developer.android.com/reference/android/content/Intent.html#EXTRA_LOCAL_ONLY). Be sure to make a check of the API before using it. – ol_v_er Aug 12 '13 at 21:55
  • 1
    It resolves to a constant. In pre-honeycomb you could specify the constant string "android.intent.extra.LOCAL_ONLY" – Paul Oct 24 '14 at 19:44
  • How to restrict external sdcard from this intent? – Noundla Sandeep Jan 08 '16 at 14:57
-3

User this code to launch intent to get local image chooser.

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);

startActivityForResult(Intent.createChooser(intent,
                "Complete action using"), PHOTO_PICKER_ID);
Arslan Anwar
  • 18,746
  • 19
  • 76
  • 105