Quitting application in Android

前端 未结 3 1214
孤城傲影
孤城傲影 2021-01-14 13:22

I want to quit application in Android. Just put a \"quit\" button, which kills my app.

I know I shouldn\'t do this. I know that this is not the philosophy of the OS.

3条回答
  •  猫巷女王i
    2021-01-14 13:55

    Your answer helped me, Pentium10, but I needed to do one more thing :

    I had to clear(close) all my previous activities with

    Intent i = new Intent();

    i.setClass(this, FirstActivity.class);

    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    startActivity(i);

    This means: every activity, started after FirstActivity, is closed. (In other words, this cleans the activity stack above FirstActivity). Then all I have to do is finish my FirstActivity.

提交回复
热议问题