Intent.FLAG_ACTIVITY_CLEAR_TOP doesn't deletes the activity stack

后端 未结 10 915
遇见更好的自我
遇见更好的自我 2020-12-17 09:20

I am developing the application in which i want to close whole application on button click. I know in android we should not think about to close the application because andr

10条回答
  •  佛祖请我去吃肉
    2020-12-17 09:57

    As other answers have the following should work.

    Intent intent = new Intent(Activity3.this, FinishActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    

    For API level < 11, Intent.FLAG_ACTIVITY_CLEAR_TASK is not available. Instead I used IntentCompat.FLAG_ACTIVITY_CLEAR_TASK from support library.

    See IntentCompat

    Might help someone stumbling across.

提交回复
热议问题