Android Closing Activity Programmatically

后端 未结 5 1180
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 00:03

What is the equivalent operation within an activity to navigating away from the screen. Like when you press the back button, the activity goes out of view. How can this be call

相关标签:
5条回答
  • 2021-02-01 00:38

    finish() method is used to finish the activity and remove it from back stack. You can call it in any method in activity. But make sure you close all the Database connections, all reference variables null to prevent any memory leaks.

    0 讨论(0)
  • 2021-02-01 00:42

    you can use this.finish() if you want to close current activity.

    this.finish()
    
    0 讨论(0)
  • 2021-02-01 00:44

    What about the Activity.finish() method (quoting) :

    Call this when your activity is done and should be closed.

    0 讨论(0)
  • 2021-02-01 00:44

    you can use finishAffinity(); to close all the activity..

    0 讨论(0)
  • 2021-02-01 00:51

    You Can use just finish(); everywhere after Activity Start for clear that Activity from Stack.

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