captureSingleRemoteDocument
Source set: Android
public suspend fun captureSingleRemoteDocument(
context: Context,
creationDisplayInfo: RemoteCreationDisplayInfo = createCreationDisplayInfo(context),
remoteDensity: RemoteDensity =
RemoteDensity(
creationDisplayInfo.density.density.rf,
creationDisplayInfo.density.fontScale.rf,
),
layoutDirection: LayoutDirection =
toLayoutDirection(context.resources.configuration.layoutDirection),
clock: RemoteClock = RemoteClock.SYSTEM,
profile: Profile = RcPlatformProfiles.ANDROIDX,
writerEvents: WriterEvents = WriterEvents(),
content: @Composable @RemoteComposable () -> Unit,
): CapturedDocument
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 CapturedDocument which contains the serialized bytes and metadata.
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 system layout direction. |
| 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. |
Returns
| A CapturedDocument containing the serialized document bytes. |