Intent.FLAG_ACTIVITY_CLEAR_TOP doesn't deletes the activity stack

后端 未结 10 854
遇见更好的自我
遇见更好的自我 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 10:08

    Try Like this Way this is work for me:

    Intent intent = new Intent(Activity3.this, FinishActivity.class);
    intent.addFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    finish();
    

    instead of your code

    Intent intent = new Intent(Activity3.this, FinishActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    finish();
    

提交回复
热议问题