In an Android app, I have two activities; lets call them A and B. A is the main activity, and it contains a button that calls startActivity() to display B. In short:
A -> B
A has a thread that ticks every minute. On this tick, a notification is updated in the status bar
This is what I am after:
1) When the user clicks the notification when neither A nor B is visible, show A
2) When the user clicks the notification when A is visible, nothing should happen
3) When the user clicks the notification when B is visible, nothing should happen (or, if it is easier, pop B to show A)
1) and 2) are easy to accomplish. 3) will start a new version of A and add it to the queue:
A -> B -> A, which is not what I intended. The user has to press back three times to go to the home screen
Is there a way to ensure that clicking the notification will either show the stack A -> B or A alone?
You should set the flag of activity A to singleTask and catch the new
startActivity()intent to theonNewIntent(Intent i)of activity A (which you should override). Hope this helps!