How to close an android application?

后端 未结 6 822
遥遥无期
遥遥无期 2020-12-06 01:35

There are many question regarding this topic but there is no clear answer. Although android\'s memory management is very solid, so many people believe that we shouldn\'t kil

6条回答
  •  清歌不尽
    2020-12-06 01:54

    If you want to exit from an activity use finish() method of the activity, as Lucifer has suggested. It will simply finish the current activity. But if you want to exit from application(destroy all the activities upto Home Screen) use following Block of Code:

    Intent intent=new Intent(this, HomeClass.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    

提交回复
热议问题