That is not a robust design. For example: - you have activity A and activity B on top of it - the user leaves your app - your process gets killed - the user now switches back to your app. - a new activity B is created to show the user in their last state.
At this point there is no activity A instance, because there has been no need to show it since the process was killed. On Thu, Aug 5, 2010 at 9:27 AM, Jin Chiu <[email protected]> wrote: > My root Activity maintains an AIDL connection to a Service. Depending > on operations it receive from the Service, it will issue commands to > children Activities that were spawned in the foreground. When the > entire Activity stack goes into the background, the root Activity must > be able to notify the Service so it can post messages to the > NotificationManager instead of sending them directly to a Task in the > background. > > The problem with simpling setting a flag when launching a new activity > is the RootActivity still cannot tell when the entire task get > switched, since onStop() is only called once. Consider the scenario > where the RootActivity spawned a ChildActivity in the foreground. If > the user then switches to another Task, RootActivity still cannot tell > that its current Task is going into the background. > > On Aug 5, 10:27 am, TreKing <[email protected]> wrote: > > On Thu, Aug 5, 2010 at 9:06 AM, Jin Chiu <[email protected]> wrote: > > > I would like to get notified when the user has switched to another > > > application. > > > > Out of curiosity, why? > > > > > In this case, onStop() in MyActivityA does not suffice as that will > also > > > get invoked if the user navigates to another screen within my app. > > > > Maybe set a flag indicating that you've launched a new activity yourself, > so > > onStop if your flag is set, it was you. If not, the user switched using > > other means. Yes, this is a hack and will probably break in subtle ways. > > Good luck. > > > > > --------------------------------------------------------------------------- > ---------------------- > > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago > > transit tracking app for Android-powered devices > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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

