Intent.FLAG_ACTIVITY_CLEAR_TOP doesn't deletes the activity stack

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

    This finally worked for me 100% of the time. I tried all of the flags standalone, never worked for all instances of the code. Used all the flags everywhere I want this functionality, about 5 different places, and it now works.

                Intent intent = new Intent(actvSignIn.this, actvNearbyPlaces.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                finish();
    

提交回复
热议问题