androidx.activity.compose

Classes

ManagedActivityResultLauncher

A launcher for a previously-prepared call to start the process of executing an ActivityResultContract.

Objects

Composables

BackHandler

An effect for handling presses of the system back button.

PredictiveBackHandler

An effect for handling predictive system back gestures.

ReportDrawn

Calls Activity.reportFullyDrawn after this composition is completed.

ReportDrawnAfter

Adds block to the methods that must complete prior to Activity.reportFullyDrawn being called.

ReportDrawnWhen

Adds predicate to the conditions that must be met prior to Activity.reportFullyDrawn being called.

rememberLauncherForActivityResult

Register a request to start an activity for result, designated by the given ActivityResultContract.

Extension functions summary

Unit
ComponentActivity.setContent(
    parent: CompositionContext?,
    content: @Composable () -> Unit
)

Composes the given composable into the given activity.

Top-level properties summary

ProvidableCompositionLocal<Activity?>

Provides the Activity belonging to the current LocalContext.

Extension functions

ComponentActivity.setContent

fun ComponentActivity.setContent(
    parent: CompositionContext? = null,
    content: @Composable () -> Unit
): Unit

Composes the given composable into the given activity. The content will become the root view of the given activity.

This is roughly equivalent to calling ComponentActivity.setContentView with a ComposeView i.e.:

setContentView(
ComposeView(this).apply {
setContent {
MyComposableContent()
}
}
)
Parameters
parent: CompositionContext? = null

The parent composition reference to coordinate scheduling of composition updates

content: @Composable () -> Unit

A @Composable function declaring the UI contents

Top-level properties

LocalActivity

val LocalActivityProvidableCompositionLocal<Activity?>

Provides the Activity belonging to the current LocalContext.

Note, when possible you should always prefer using the finer grained composition locals where available. This API should be used as a fallback when the required API is only available via Activity.

See androidx.compose.ui.platform.LocalConfiguration androidx.compose.ui.platform.LocalView