Question

I have read into the finish(); commands and the FLAG_ACTIVITY_CLEAR_TOP commands and also checked out Common Ware's answer on killing app, but I am not sure how to put this into my app.

Basically, I have a user click a button that takes them to the camera. The user then snaps a photo and it brings them to a layout view. The user then clicks a button that takes them to one of 2 views, depending on a some conditions.

The user is then allowed to either retake a photo, or go to the main menu (depending). My problem is, if the user goes back to the main menu, and snaps another, then another, etc...the activities stack, so when I click the 'Main Menu' button the app goes back through eached stack activity until finally it goes back to the main menu. Is there a way to kill each activity with one of these lines, so even if a user retakes a photo, they will only need to go back once to get to the main menu?

Thanks for anyhelp.

Was it helpful?

Solution

You could use the noHistory flag which would end each activity once you're away from it. Probably though, what you really want is singleTop launch mode, that will return to your previously opened activity rather than making a new instance of it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top