htjxxg
Last Updated: February 25, 2016
·
2.454K
· alberovalley
Iznogud

Start android image picker for local files only

When we start the android image picker, unless we specify otherwise, it will display images both local and remote. If we intend to work only with local images, this is the way to go

// this starts the image picker
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
photoPickerIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); // this is the flag that does the trick
startActivityForResult(photoPickerIntent, SELECT_PHOTO);  


// this goes in onActivityResult(int requestCode, int resultCode, Intent data)
case SELECT_PHOTO:
    if(resultCode == Activity.RESULT_OK){
        Uri imageUri = data.getData();
        // do stuff with the imageUri
    }
Say Thanks
Respond

1 Response
Add your response

5900

Too bad it's only available from the level 11:
http://developer.android.com/reference/android/content/Intent.html#EXTRA_LOCAL_ONLY

Good tips, though!

over 1 year ago ·