How to force stop my android application programmatically?

前端 未结 6 992
天涯浪人
天涯浪人 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:25

    Note: This does not kill the entire app, but if what you want to do is to finish all the app activities, this is the best option.

    Android ≥ 16

    finishAffinity();

    Android < 16

    ActivityCompat.finishAffinity(Activity activity)

    Hope this helps

提交回复
热议问题