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
}
Written by Frank
Related protips
1 Response
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#