Function

captureSingleRemoteDocument

Capture a single RemoteCompose document from the specified content Composable by rendering it once inside a virtual display.

captureSingleRemoteDocument

Source set: Android
public suspend fun captureSingleRemoteDocument(
    context: Context,
    creationDisplayInfo: RemoteCreationDisplayInfo = createCreationDisplayInfo(context),
    remoteDensity: RemoteDensity =
        RemoteDensity(
            creationDisplayInfo.density.rf,
            creationDisplayInfo.fontScale.rf,
        ),
    layoutDirection: LayoutDirection =
        toLayoutDirection(context.resources.configuration.layoutDirection),
    clock: RemoteClock = RemoteClock.SYSTEM,
    profile: Profile = RcPlatformProfiles.ANDROIDX,
    writerEvents: RemoteWriterEvents = RemoteWriterEvents(),
    content: @Composable @RemoteComposable () -> Unit,
): RemoteCapturedDocument

Capture a single RemoteCompose document from the specified content Composable by rendering it once inside a virtual display.

This is a suspending function that performs the composition and rendering, returning a RemoteCapturedDocument which contains the serialized bytes and metadata.

Example of capturing a single RemoteCompose document as a byte array:

Parameters

context The Android Context to use.
creationDisplayInfo Details about the virtual display to capture for (size, density, etc.). Defaults to display metrics derived from context.
remoteDensity The logical screen density and font scale to use for unit conversions. Defaults to density derived from creationDisplayInfo. Note: If passing custom values, they should typically match the density and font scale specified in creationDisplayInfo to avoid layout scaling discrepancies.
layoutDirection The layout direction (LTR or RTL) to use. Defaults to the layout direction of context's configuration.
clock The clock used for the composition timeline. Defaults to RemoteClock.SYSTEM.
profile The writing profile that determines supported operations. Defaults to RcPlatformProfiles.ANDROIDX.
writerEvents Callback to handle non-serializable events (e.g. pending intents).
content The Composable content to render and capture.

Return

A RemoteCapturedDocument containing the serialized document bytes.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: