When I run my app on the debugger, I get the main thread and 3 binder threads.
On a button click I call Activity.finish(), which looks like it ends the activity as the UI closes and goes back to the home screen.
However, in the debugger, it still shows the main thread and 3 binder threads as "(running)".
I am baffled to why this is happening. Even more so, it is causing my app to call Activity.onResume() when I run it again after exiting the app.
I currently override these methods in the Activity, but I call the appropriate super functions in each one:
Any help or advice regarding this is much appreciated!
On Clicking the back button from the New Activity, the finish() method is called and the activity destroys and returns to the home screen.
You can do the same thing as the Back button, that is, close the current activity by calling a function named finish.
You don't control when your app leaves main memory, the OS does. Look closely at Activity.finish...
Call this when your activity is done and should be closed. The ActivityResult is propagated back to whoever launched you via onActivityResult().
Note that is says nothing about memory. As to calling Activity.onResume, that's exactly what you would expect for the lifecycle; remeber that onResume is not just called after a resume but even when the app is first launched after onCreate.
While not exactly what you asked I suggest you read this article about exit buttons which goes on to say something very important
[Activity.finish] is exactly equivalent to hitting the back button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With