However... This did raise an interesting observation. When I decide that my Activity is duplicated (in onCreate()), and call finish(), onResume() and onDestroy() are then called. I would have expected only onDestroy () :-/
Not a problem, the counter still does its job. Ian Hunter On Nov 30, 7:41 pm, "[email protected]" <[email protected]> wrote: > Yea, that does it - thanks. > > I was thinking I might have missed a means of detecting that the > Activity was already on the stack or something clever. > > BTW: Do we have programmatic access to the Component stack? > > Ian > > On Nov 30, 6:56 pm, schwiz <[email protected]> wrote: > > > perhaps a static int variable of the number of active instances that > > is incremented in on create and decremented in ondestroy? > > > On Nov 30, 12:43 pm, "[email protected]" > > > <[email protected]> wrote: > > > I have an Activity which is launched from a Service. This Activity can > > > spawn other children Activities. > > > > Now under certain conditions (particularly related to using screen > > > lock), I can end up with the Service starting a second copy of the > > > Activity again. > > > > For reasons of performance, the Service is being started and stopped > > > at various times, and cannot be relied on to hold state. > > > > What is the best way to prevent this second launch? > > > Can I (for example) detect that the Activity is already running in the > > > stack and do finish()? > > > > This feels like it should be straight forward - perhaps I'm being > > > thick - forgive me. > > > > Thanks for any help > > > > Ian Hunter -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

