Here’s the scenario:
- In activity
AI have “post to Twitter” option which calls activityBthat executes the post and returns toAby executingActivity#finish()and the flow isA->B->A - However, if I’m not logged into Twitter then the
Bactivity calls Twitter mobile OAuth page in the browser. Then browser redirects user back toB. However whenBis done and I callActivity#finish()I’m returning back to the browser login page which is expected since the stack is nowA->B->browser->B.
How do I go 3 steps back instead of just one? Is it even possible? I don’t want to call A anew since at the very least I will lose a list position
You can do this with FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_SINGLE_TOP.
You need to launch A as a new Intent but set those two flags before calling
startActivityClear Top causes all activities on top of A to get cleared away.
Single Top causes the intent to be delivered to A’s
onNewIntentmethod instead of destroying and recreating A.From the docs: