GetContent

class GetContent : ActivityResultContract<String!, Uri!>
kotlin.Any
   ↳ androidx.activity.result.contract.ActivityResultContract<kotlin.String, android.net.Uri>
   ↳ androidx.activity.result.contract.ActivityResultContracts.GetContent

An ActivityResultContract to prompt the user to pick a piece of content, receiving a content:// Uri for that content that allows you to use android.content.ContentResolver#openInputStream(Uri) to access the raw data. By default, this adds Intent#CATEGORY_OPENABLE to only return content that can be represented as a stream.

The input is the mime type to filter by, e.g. image/*.

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

Summary

Public constructors

An ActivityResultContract to prompt the user to pick a piece of content, receiving a content:// Uri for that content that allows you to use android.content.ContentResolver#openInputStream(Uri) to access the raw data.

Public methods

open Intent
createIntent(@NonNull context: Context, @NonNull input: String)

ActivityResultContract.SynchronousResult<Uri!>?
getSynchronousResult(@NonNull context: Context, @NonNull input: String)

Uri?
parseResult(resultCode: Int, @Nullable intent: Intent?)

Public constructors

<init>

GetContent()

An ActivityResultContract to prompt the user to pick a piece of content, receiving a content:// Uri for that content that allows you to use android.content.ContentResolver#openInputStream(Uri) to access the raw data. By default, this adds Intent#CATEGORY_OPENABLE to only return content that can be represented as a stream.

The input is the mime type to filter by, e.g. image/*.

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

Public methods

createIntent

@CallSuper @NonNull open fun createIntent(
    @NonNull context: Context,
    @NonNull input: String
): Intent

getSynchronousResult

@Nullable fun getSynchronousResult(
    @NonNull context: Context,
    @NonNull input: String
): ActivityResultContract.SynchronousResult<Uri!>?

parseResult

@Nullable fun parseResult(
    resultCode: Int,
    @Nullable intent: Intent?
): Uri?