1

Using android, I was wondering if it was a proper and clean way to clear the whole backstack?

I found many answers on SO for that but they all make me pop to the top element. What I need is just a simple way to clean the backstack in order to keep it clean after some advanced process deep into my fragments.

I don't need ( and I don't want ) to change my current fragment or to start a new activity ( for a perfomance purpose ). All I need is an empty backstack to avoid further troubles.

Thanks in advance!

Virthuss
  • 3,142
  • 1
  • 21
  • 39
  • Afaik, you cannot just "clear it", you have to start a new activity with the intents flag `FLAG_ACTIVITY_NEW_TASK` and `FLAG_ACTIVITY_CLEAR_TOP` A proposition is to start your activity with `FLAG_ACTIVITY_NO_HISTORY` tag, or override the back button so people cannot navigate back – Nikola Oct 21 '15 at 07:38
  • But restarting my activity would be to greedy in term of performance, I'm actually changing some parts of my app to avoid performance issue and restarting my app was a way for me to start again on clean bases after some long process. However being to needing in term of resources, I cannot do that anymore. – Virthuss Oct 21 '15 at 07:41
  • Just to see if I understood correctly: What you want is to remove all the fragments from the backstack but stay with your current Fragment on the screen? – Budius Oct 21 '15 at 10:03
  • yes, that's exactly that. – Virthuss Oct 21 '15 at 10:37

0 Answers0