Skip to content

Commit

Permalink
ndk-glue: Finish native activity after returning from main()
Browse files Browse the repository at this point in the history
When an application returns its control flow back from `main()` it is
generally assumed to be done polling on the looper and wishes to
terminate.  Android is made aware of this by calling
`ANativeActivity_finish`, otherwise it'll continue sending input events
and eventually ANR as the app didn't consume them anymore.
  • Loading branch information
MarijnS95 committed Jul 24, 2021
1 parent 49e8ed5 commit 10cbc84
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ndk-glue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ pub unsafe fn init(
signal_looper_ready.notify_one();
}

main()
main();

NATIVE_ACTIVITY
.take()
.expect("Native activity should not have been taken before main() returns!")
.finish()
});

// Don't return from this function (`ANativeActivity_onCreate`) until the thread
Expand Down

0 comments on commit 10cbc84

Please sign in to comment.