开发者

Android Closing Activity Programmatically

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 called from inside an activity so that it closes it开发者_Go百科self.


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

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


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

this.finish()


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜