I have an app that has a list as its main activity and then you can click items which opens a detailed view of that item. I also have a search activity that is similar to the main activity and works as intended.
However I want this search activity to only have once instance on the stack so that users can search multiple times and clicking back would return them to the previouse view that they were on before they started searching (rather than go back to the previouse search results)
both the singleTask and singelInstance launch mode seems to do what I want so Im not sure which one I should be using for this purpose and why?
From the Application Fundamentals page of the Android dev guide:
Since there is never more than one instance of the Activity with either launch mode, the back button will always take you to the existing instance of the Activity in your case.
An important difference is that "singleTask" doesn’t require the creation of a new task for the new Activities being launched when something is selected. Nor will it have to remove that new task on the back button each time.
Since your Activity stack does all pertain to one user "task", and it doesn’t sound like you have an intricate Intent structure where singleInstance may be beneficial to always handle them, I would suggest using the singleTask launch mode.
Here is a good blog post for more info, as well as credited for the image: Android Activities and Tasks series – An introduction to Android’s UI component model