Yes but you’ll need to use Intent.ACTION_SEND_MULTIPLE instead of Intent.ACTION_SEND .
Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files."); intent.setType("image/jpeg"); /* This example is sharing jpeg images. */ ArrayList<Uri> files = new ArrayList<Uri>(); for(String path : filesToSend /* List of the files you want to send */) { File file = new File(path); Uri uri = Uri.fromFile(file); files.add(uri); } intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files); startActivity(intent);
My Own Solution
private fun shareSelectedFiles() { val files = ArrayList<Uri>() CachePupli.selectedMediaList.forEach { s: String -> val uri = Uri.parse("file:///$s") files.add(uri) } val intent = Intent(Intent.ACTION_SEND_MULTIPLE) intent.setType(FileHelper().getMimeType(files.get(0).path)) intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files) val clipData = ClipData.newUri(contentResolver, "Share", files.get(0)); if (files.size > 1) { var i = 1 while (i < files.size) { clipData.addItem(ClipData.Item(files.get(i))) i++ } } intent.clipData = clipData startActivityForResult(Intent.createChooser(intent, "Share"), 10001) } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { // after sharing multiple files if (requestCode == 10001) { CachePupli.selectMediaMode = false EventBus.getDefault().post(ChangeSelectionModeStatusEvent(false)) } super.onActivityResult(requestCode, resultCode, data) }
References
https://stackoverflow.com/questions/15577438/how-can-i-share-multiple-files-via-an-intent