How to force stop my android application programmatically?

前端 未结 6 982
天涯浪人
天涯浪人 2020-11-27 05:59

I\'d like to force stop my Android application when I click closeButton. This is my code.

protected void onCreate(Bundle savedInstanceState) {

  this.setCon         


        
6条回答
  •  难免孤独
    2020-11-27 06:23

    A bad way to kill the application would be System.exit(0)

    Edit: I believe I owe some explanation. Android handles the application lifecycle on its own, and you are not supposed to 'ForceClose' it, and I don't know any good way to do it. Generally its ok if your application is still alive in the background, this way if user launches it again it will pop up quickly.

提交回复
热议问题