Selection limit to file picker #112
Answered
by
anggrayudi
AkshayAshokCode
asked this question in
Q&A
-
Hey! Is it possible to add a limit to file picker selection? |
Beta Was this translation helpful? Give feedback.
Answered by
anggrayudi
Jan 18, 2023
Replies: 1 comment 3 replies
-
Currently, there's no First alternative: Request again after the files are selected. storageHelper.onFileSelected = { requestCode, files ->
if (files.size > 4) {
Toast.makeText(this, "Please select max 4 files", Toast.LENGTH_SHORT).show()
storageHelper.openFilePicker(REQUEST_CODE_PICK_FILE, true)
} else {
// do stuff
}
} Second alternative: Take only as many as elements you need. storageHelper.onFileSelected = { requestCode, files ->
val selected = files.take(4)
} I'll update this answer once Google added this capability via |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
anggrayudi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, there's no
Intent.EXTRA_*
in Android framework to set maximum selected files. But you have 2 alternatives:First alternative: Request again after the files are selected.
Second alternative: Take only as many as elements you need.
I'll update this answer once Google added this capability via
Intent.EXTRA_*