Magnus Lundberg
09/07/2023, 5:17 PMKirill Grouchnikov
09/07/2023, 5:19 PMMichael Paus
09/07/2023, 5:20 PMKirill Grouchnikov
09/07/2023, 5:21 PMMagnus Lundberg
09/07/2023, 5:24 PMMichael Paus
09/07/2023, 5:29 PMfun main(args: Array<String>) {
ModelBridge.initialize(args)
ModelBridge.configure()
application(exitProcessOnExit = false) { // This is needed so that ModelBridge.stop() is called at the end.
val windowState = rememberWindowState(size = DpSize(1200.dp, 900.dp))
var isMinimized by remember { mutableStateOf(true) }
Window(
onCloseRequest = ::exitApplication,
title = "JavaForumStuttgartApp",
state = windowState,
) {
LaunchedEffect(windowState) {
snapshotFlow { windowState.isMinimized }
.filter { isMinimized != it }
.onEach {
isMinimized = it
if (isMinimized) ModelBridge.stop() else ModelBridge.start()
}
.launchIn(this)
}
MainView()
}
}
ModelBridge.stop()
exitProcess(0) // This is needed because we set exitProcessOnExit = false.
}
See the isMinimized state.Michael Paus
09/07/2023, 5:32 PMoverride fun applicationDidEnterBackground(application: UIApplication) {
for example and on Android you have similar methods in the Activity.
All platforms have different life-cycle concepts and you somehow have to handle them all yourself and map them onto the life-cycle requirements of your application.