Properties used to customize the behavior of a [Dialog].
DialogFromServiceSample
@Composable
fun DialogFromServiceSample() {
// In a real Service scenario, appWindowToken would be received via IPC
// from the main application process. This sample simulates having the token.
val appWindowToken: IBinder? = null // Provided via IPC
var showDialog by remember { mutableStateOf(false) }
Button(onClick = { showDialog = true }) { Text("Show Dialog From Service") }
if (showDialog) {
Dialog(
onDismissRequest = { showDialog = false },
properties =
DialogProperties(
// Pass the application's window token
windowToken = appWindowToken
),
) {
Box(Modifier.size(250.dp, 150.dp).background(Color.DarkGray)) {
Text("Dialog Content (Service)", color = Color.White)
}
}
}
}