ndk icon indicating copy to clipboard operation
ndk copied to clipboard

Exiting the app

Open zmerp opened this issue 4 years ago • 2 comments

When the function tagged with #[ndk_glue::main] returns, the app hangs, unless ndk_glue::native_activity().finish() is called just before. Should the ndk_glue::main append ndk_glue::native_activity().finish() at the end of the function?

zmerp avatar Jul 19 '21 13:07 zmerp

@zarik5 Thanks for reporting! I have definitely been thinking about calling it after fn main():

https://github.com/rust-windowing/android-ndk-rs/blob/49e8ed51220567dccac9fd1e8baa526e9cdac163/ndk-glue/src/lib.rs#L183-L202

We can perform and publish this as a breaking change as it might potentially break an application that spawns its own thread while accidentally returning from fn main() when the app (and looper etc) is still very much alive.

MarijnS95 avatar Jul 24 '21 21:07 MarijnS95

We've had quite the discussion in #160 and automatically calling .finish() upon returning from fn main() seems undesirable at best; applications will have to call it themselves.

I'll think about how to best resolve this issue; probably by updating some examples and documentation to explicitly call this function.

MarijnS95 avatar Aug 07 '21 17:08 MarijnS95

closing for now, please reopen in https://github.com/rust-mobile/android-activity if still relevant

dvc94ch avatar Dec 06 '22 20:12 dvc94ch