Android: Clear the back stack

前端 未结 30 1837
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 06:47

In Android I have some activities, let\'s say A, B, C.

In A, I use this code to open B:

Intent intent = new Intent(this, B.class);
startActivity(inte         


        
30条回答
  •  渐次进展
    2020-11-22 07:37

    If your application has minimum sdk version 16 then you can use finishAffinity()

    Finish this activity as well as all activities immediately below it in the current task that have the same affinity.

    This is work for me In Top Payment screen remove all back-stack activits,

     @Override
    public void onBackPressed() {
             finishAffinity();
            startActivity(new Intent(PaymentDoneActivity.this,Home.class));
        } 
    

    http://developer.android.com/reference/android/app/Activity.html#finishAffinity%28%29

提交回复
热议问题