April 22, 2025 · 1 min read
Normally, a Bevy application can exit with AppExit, like:
fn exit_system(mut exit_event: MessageWriter<AppExit>) {
exit_event.write(AppExit::Success);
}
But on Android, that is not enough and can cause the app fails to reopen.
To completely exit the Bevy application on Android, we need to exit on the Android side too.
.--------------------------------------. .------------------------------.
| Bevy | | Android |
| .------------. .------------. | | .------------. |
| | system | | main | | | | MainActivity | |
| '-----+-+----' '-----+-+----' | | '-----+-+----' |
| | | AppExit | | | | | | |
| +-+--------------->| | | | | | |
| | | exitAppActivity | | |
| +-+---------------------------->| | |
| | | | +---. |
| | | | | | finishAffinity |
| | | | | | |
| | | +-+<--' |
| | | |
'--------------------------------------' '------------------------------'
Read More...