Android: Clear the back stack

前端 未结 30 2423
被撕碎了的回忆
被撕碎了的回忆 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:47

    Starting in API 16 (Jelly Bean), you can just call finishAffinity().

    Now you can also call ActivityCompat.finishAffinity(Activity activity) with the compatibility library.

    Be sure to set taskAffinity in the manifest to a package name unique to that group of activities.

    See for more info:
    http://developer.android.com/reference/android/support/v4/app/ActivityCompat.html#finishAffinity%28android.app.Activity%29

提交回复
热议问题