简体   繁体   中英

allow user to select only 5 images in android studio

How to enable user select only 5 images from gallery

Intent intent = new Intent(); intent.setType("image/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(Intent.createChooser(intent,"Select Picture"), 1);

I tried this but didn't restrict from 5 images only

Intent intent = new Intent(); intent.setType("image/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(Intent.createChooser(intent,"Select Picture"), 1);

Presently, there is nothing for this in Android.

Android 13 is set to introduce a photo picker that does allow you to limit the number of selected images. The docs hint that Google might make this available for slightly older devices, back to Android 11.

Otherwise, see if there is a library that does what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM