0

So I'm having trouble managing the Backstack in my Android app.

My application essentially contains a Navigation Drawer where each option starts a new Activity. I have designed a BaseActivity which contains all the Navigation Drawer initialisations, from which the other activities extend so that they all have the same Navigation Drawer. (I do not use fragments anywhere).

The problem is that each time the back button is pressed (in any activity), the Navigation Drawer either opens or closes.

How can I remove the Navigation Drawer from the Backstack considering it is an Activity that the other Activities extend from and is not launched anywhere with an Intent?

Pankaj
  • 7,908
  • 6
  • 42
  • 65
Bob Bob
  • 154
  • 1
  • 11
  • Post your code. What you have done in `BaseActivity - onBackPressed()` and in `ChildActivity - onBackPressed()` method. – Pankaj Jul 07 '15 at 11:38
  • Ah, I just found a small mistake in onBackPressed(). Stupid of me not to have checked it properly.Thank you for making me look there! – Bob Bob Jul 07 '15 at 12:39
  • Your welcome, happy to solve your problem. – Pankaj Jul 08 '15 at 05:50
  • @BobBob, I realize this is an old question now but I have run into this exact behavior while trying to implement the ActionBar/Toolbar, except that I have not overridden onBackPressed() in any of the Activities. If you still remember what was wrong back then, would you mind posting an answer to your question that includes the issue you found and how you resolved it? – Ben Bloodworth Feb 23 '21 at 22:04
  • @BenBloodworth really wish I could help you man. I don't remember exactly what was wrong, but looking at my comment, I must've overridden onBackPressed() somewhere and then just deleted the override. If you're sure you haven't overridden it, I guess my solution wouldn't have been helpful any way. Best of luck! – Bob Bob Feb 25 '21 at 02:50

0 Answers0