How can I have an activity return to another activity rather than the one called startactivity?
I have a game in which the user can select to play from a list of existing games or select to start a new game. When starting a new game, I’d like it when the user finishes his turn if the list of games becomes active rather than going back to activity to create a new game.
Among the various activities,
What it currently does:
selectGames
playGame --- return to selectGames
or
createNewGame --- playGame --- return to createNewGame --- return to selectGames
I’d like it to:
selectGames
playGame --- return to selectGames
or
createNewGame --- playGame --- return to selectGames
Is there a way to insert an intent or so that when starting an activity from createNewGame
the user can finish or pause the game and go back to selectGames? If intents are on the stack, I’d like to remove createNewGame from the stack of intents (does that makes sense?)
I believe adding
android:noHistoryto thecreateNewGameActivity in the manifest will accomplish what you wantFrom the docs:
android:noHistory
A value of “true” means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it.
This attribute was introduced in API Level 3.