How i can close/exit button on my app?

前端 未结 6 1735
慢半拍i
慢半拍i 2021-01-23 20:45

i have a button to close my app with this code:

finish();

the problem is that this button doesn\'t exit of my app... it simply closes the current intent ant retu

6条回答
  •  庸人自扰
    2021-01-23 21:35

    By default Android's design doesn't favour exiting an application, but rather allows the OS to manage it. You can bring up the Home application by it's corresponding Intent:

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    

提交回复
热议问题