TL;DR:
How can I give one intent a preference over another?
If two intents are run at the same time, I want only one of those intents to start.
My game has a 20 second timer running in the background service, and when that timer ends, a new activity (game over screen) starts through an intent. The user is pressing buttons to change activities (again, through intent) in those 20 seconds.
The problem is, if the user pushes a button at the same time that the timer ends, the next activity starts rather than the game over screen. Now, the timer is over, and the user is stuck randomly pushing buttons for no reason. How can I fix this? Is there any way to make sure that the Game Over screen will open up after 20 seconds?
I haven't provided much code, because it is mainly just starting intents. If you need any detail, feel free to ask me.
I am suggesting you to take a global variable as a flag, let say
int = 0
Now initialize it as "0" and on your both intents give condition as below:,And then flush that variable to "0" whenever you want.Hope you got idea.
do timer checking on user click event should do it. or you can use flag/boolean to maintain state.
i dont know your code, just use simple conditional if..