I'm trying to select multiple files with an Intent, but it seems like I'm missing on something.
I create an Intent.ACTION_GET_CONTENT Intent, put Intent.EXTRA_ALLOW_MULTIPLE as extra in
(it seems to perfectly fit the purpose) and create a chooser (optional), which chooses the application that should be able to pick multiple files and return them.
The Problem is that I can only pick a single file.
I tried multiple file explorers. It's API 18 (4.3).
ACTIVITY_CHOOSE_FILE = 1; //global constant
Button btn = (Button) this.findViewById(R.id.btnGetFiles);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent chooseFile;
Intent intent;
chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
chooseFile.setType("file/*");
chooseFile.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent = Intent.createChooser(chooseFile, "Choose a file");
startActivityForResult(intent, ACTIVITY_CHOOSE_FILE);
}
});
I also added this to the Manifest (it had the same functionality before adding it):
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Why can't I choose multiple files?
(For clarification: the problem is not, that multiple files aren't returned - I can't choose more than 1 file)
I know it's a bit outdated post but still if someone encounters it: in this sample, we open default system file explorer to allow a user select multiple files of any type on his device:
I got same issue. Here my solution.
Java:
Kotlin:
I got the same issue and
ACTION_OPEN_DOCUMENT
worked for me.Presumably, the implemeters of "the application that should be able to pick multiple files and return them" have not implemented
EXTRA_ALLOW_MULTIPLE
support. Contact them and request this feature.