Q:

Android - How to limit activity instances to one per list item?

I have FooListActivity (one instance, showing a list of all the foos) and FooActivity (zero or one instance per foo).
FooActivities can be started from the FooListActivity, but also from a long-running service with no user intervention.
How can I make sure that, at most, one FooActivity exists per foo?
i.e. If I try to start a FooActivity for a foo which already has a FooActivity, it should bring the existing FooActivity to the front, rather than creating an unneeded instance.

A:

If I understand you correctly you do not want just a single instance of your activity (which you can control with android:launchMode="singleInstance"), but you want single instance per displayed content? If so, you will have to keep track of this yourself. 
Also, I am not sure this is a good idea at all. While I can imagine some usage patterns for this on tablet (but then with Fragments, not Activities), then on phone user need to get back to list to see another data anyway (and if setting up FooActivity to display data is heavy, then you should perhaps think of some caching instead?

