How to finish multiple activities on a button click?

前端 未结 2 736
死守一世寂寞
死守一世寂寞 2021-01-07 23:58

I am implementing android application which is on web service. I\'m creating login Activity A then homepage Activity B and so on.

Suppose t

相关标签:
2条回答
  • 2021-01-08 00:35

    Take a look at the FLAG_ACTIVITY_CLEAR_TOP flag.

    In essence it does the following. If the Activity this Intent is directed to is paused in your current back stack then it will resume it and clear the stack above it destroying all the activities in the stack above it.

    UPDATE: In response to Jason Hanley.

    Thanks for mentioning it. The documentation of FLAG_ACTIVITY_CLEAR_TOP covers that example. If you don't want Activity B to be recreated but just passed the new Intent then you should define its launch mode as singleTop.

    0 讨论(0)
  • 2021-01-08 00:41

    Use onActivityResult method in chain . Start closing with the outermost activity-E when pressed on home , then check for its result and accordingly close activity-D and so on .

    0 讨论(0)
提交回复
热议问题