Skip to content

Instantly share code, notes, and snippets.

@armcha
Created March 9, 2026 10:25
Show Gist options
  • Select an option

  • Save armcha/8c84c75ff661897ae0d8b6c06899dcfb to your computer and use it in GitHub Desktop.

Select an option

Save armcha/8c84c75ff661897ae0d8b6c06899dcfb to your computer and use it in GitHub Desktop.
Remote Compose — Rendering a Document on Android (RemoteComposePlayer)
/**
* Remote Compose — Rendering a document on Android
*
* Wrap RemoteComposePlayer in AndroidView to use in Compose.
* Just pass binary bytes — the player handles everything.
*/
@SuppressLint("RestrictedApiAndroidX")
@Composable
fun RemoteDocumentView(
documentBytes: ByteArray,
modifier: Modifier = Modifier,
onAction: (id: Int, metadata: String?) -> Unit = { _, _ -> },
) {
key(documentBytes.contentHashCode()) {
AndroidView(
factory = { ctx ->
RemoteComposePlayer(ctx).apply {
setDocument(documentBytes)
addIdActionListener { id, metadata ->
onAction(id, metadata)
}
}
},
modifier = modifier
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment