Is it possible to allow the user multiple file selection in the storage access infrastructure.?

After clicking the button, I receive content from the provider

Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(i, REQUESTCODE); 

Now I want to allow the user for multiple selection, is this possible.?

+7
android provider
source share
1 answer

I donโ€™t know if you solved your problem, but hereโ€™s how I implemented multiple selection using the storage platform

  Intent filePickerIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); filePickerIntent.setType("*/*"); filePickerIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(filePickerIntent, REQUEST_CODE); 

In the Result Activity method, you just need to iterate the ClipData in the Intent parameter

 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == REQUEST_CODE) { if(data != null) { ClipData clipData = data.getClipData(); for(int i = 0; i < clipData.getItemCount(); i++) { ClipData.Item path = clipData.getItemAt(i); Log.i("Path:",path.toString()); } } } } 

To select multiple files in the storage access activity user interface of the store, simply press and hold any item, and multi-selection is activated.

+7
source share

All Articles