ActivityResultContracts.PickMultipleVisualMedia


public class ActivityResultContracts.PickMultipleVisualMedia extends 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 methods

@NonNull Intent

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

final ActivityResultContract.SynchronousResult<@NonNull List<@NonNull Uri>>

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

final @NonNull List<@NonNull Uri>
parseResult(int resultCode, Intent intent)

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

Public constructors

PickMultipleVisualMedia

Added in 1.6.0
public PickMultipleVisualMedia(int maxItems)

Public methods

createIntent

Added in 1.6.0
@CallSuper
public @NonNull Intent createIntent(
    @NonNull Context context,
    @NonNull PickVisualMediaRequest input
)

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

getSynchronousResult

Added in 1.6.0
public final ActivityResultContract.SynchronousResult<@NonNull List<@NonNull Uri>> getSynchronousResult(
    @NonNull Context context,
    @NonNull PickVisualMediaRequest input
)

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

Returns
ActivityResultContract.SynchronousResult<@NonNull List<@NonNull Uri>>

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

parseResult

Added in 1.10.0-beta01
public final @NonNull List<@NonNull UriparseResult(int resultCode, Intent intent)

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