0

When my program starts, it runs a mainActivity, which right away launches and loads data into another Activity. I do this because the data needs only be loaded once, in mainActivity, then sent along to the other activities!

So! With that being said, my problem is probably forseeable! When the user clicks back enough, he will get to this initial activity, and sit there... ungracefully, instead of going back to Android's main menu.

What I want to do is add something to the onResume() method of the mainActivity, so that when it is re-entered I "activate" the back button from within the code-- (a boolean flag makes sure I'm not doing this incorrectly, thus I know it was on a back click). So isn't this just popping the current Activity from the Activity Stack?

how do I pop an activity from the activity stack!

Thanks!

Ethan Sherr
  • 413
  • 2
  • 5
  • 12

2 Answers2

1

Instead of using the "noHistory" attribute,you can also call finish() as you launch your next activity.. It will not re-appear when you then hit the "back" button.This will close the first activity.. removing it from the stack..

5hssba
  • 8,079
  • 2
  • 33
  • 35
0

Use no history option so that this activity never gets onto the backstack.

android:noHistory=["true" | "false"] 
Rajdeep Dua
  • 11,190
  • 2
  • 32
  • 22