Does onDestroy() or finish() actually kill the activity?

后端 未结 3 1728
失恋的感觉
失恋的感觉 2021-01-02 23:15

Actually I know i am asking about the simple and basic concept of Android. But I am a little bit confused about these finish() and onDestroy() meth

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-02 23:43

    The default behavior is that back button will cause the activity to exit and it'll be destroyed. Displaying a toast in onDestroy or onPause is not a good idea though. It'll alter the lifecycle the of your activity in a way you don't want it to happen. Use logging instead, so you'll see what's really happening. BTW, finish() is something that you call explicitly from your code and onDestroy() is a lifecycle event/method which gets called as a result of finishing/destoying the activity in any way.

提交回复
热议问题