Activity.finish() called but activity stays loaded in memory

前端 未结 1 1400
花落未央
花落未央 2020-11-30 11:41

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

相关标签:
1条回答
  • 2020-11-30 12:12

    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.

    0 讨论(0)
提交回复
热议问题