ActivityResultContracts.PickMultipleVisualMedia


open class ActivityResultContracts.PickMultipleVisualMedia : ActivityResultContract


An ActivityResultContract to use the Photo Picker to select multiple images, videos, or other types of visual media.

This contract always prefers the system framework provided Photo Picker available via MediaStore.ACTION_PICK_IMAGES when it is available, but will also provide a fallback on devices that it is not available to provide a consistent API surface across all Android API 19 or higher devices.

The priority order for handling the Photo Picker is:

  1. The system framework provided MediaStore.ACTION_PICK_IMAGES.

The constructor accepts one parameter maxItems to limit the number of selectable items when using the photo picker to return. When launching the activity, the minimum of maxItems and input PickVisualMediaRequest.maxItems is set as the limit.

The input is a PickVisualMediaRequest.

The output is a list Uri of the selected media. It can be empty if the user hasn't selected any items. Keep in mind that Uri returned by the photo picker aren't writable.

This can be extended to override createIntent if you wish to pass additional extras to the Intent created by super.createIntent().

Summary

Public constructors

Public functions

open Intent

Create an intent that can be used for android.app.Activity.startActivityForResult.

final ActivityResultContract.SynchronousResult<List<Uri>>?

An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity.

final List<Uri>
parseResult(resultCode: Int, intent: Intent?)

Convert result obtained from android.app.Activity.onActivityResult to O.

Public constructors

PickMultipleVisualMedia

Added in 1.6.0
PickMultipleVisualMedia(maxItems: Int = getMaxItems())

Public functions

createIntent

Added in 1.6.0
@CallSuper
open fun createIntent(context: Context, input: PickVisualMediaRequest): Intent

Create an intent that can be used for android.app.Activity.startActivityForResult.

getSynchronousResult

Added in 1.6.0
final fun getSynchronousResult(context: Context, input: PickVisualMediaRequest): ActivityResultContract.SynchronousResult<List<Uri>>?

An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity.

Returns
ActivityResultContract.SynchronousResult<List<Uri>>?

the result wrapped in a SynchronousResult or null if the call should proceed to start an activity.

parseResult

final fun parseResult(resultCode: Int, intent: Intent?): List<Uri>

Convert result obtained from android.app.Activity.onActivityResult to O.