How to exit an Android app programmatically?

前端 未结 29 999
孤城傲影
孤城傲影 2020-11-28 03:54

I am sure this question has been asked number of times because I read a few. My client wants me to put a button into his app where users can click and exit. I have read this

29条回答
  •  死守一世寂寞
    2020-11-28 04:07

    Link this method to your quit/exit button

    public void quitGame(View view) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                finishAndRemoveTask();
            } else {
                finish();
            }
        }
    

提交回复
热议问题