There is some difficulties with you proposal. -Service and UI are running on different process. -I will have to keep track of activities ( they will have to put themselves in some data structure) . - They are killed ( SIGKILL) , they won't have time to save anything neither to excute onDestroy. The problem will happen when process are launched again ( so no memory abou what happened before, just the stack of activity because framework does the job)
On Dec 28, 2:56 pm, theSmith <[email protected]> wrote: > If you want to, you can override the onDestroy() method of the service > and have it call finish() on each of you activities in the stack. > This should result in the behavior you are looking for I believe, > because the system would be forced to create a new instance of your > application, thus starting a new service with it. > > -theSmith > > On Dec 28, 10:35 am, André Oriani <[email protected]> wrote: > > > Hi all, > > > Differently from most application, the state of my application is not > > controlled by its stack of activities but by the state of a background > > service. > > > Here is my problem. Suppose I have a task running with a non empty > > stack of activities. The top activity is paused on background and not > > visible. Then for some reason the process that host both the service > > and top activity is killed. When I somehow return to my app > > application ( by pressing back key, resumimg from recent apps menu), > > the framework launches the application again with the activity that > > was on the top of the activity stack before process got killed. > > > Okay, you would say that it is the expected behavior. But because my > > service is no longer alive , the top activity is no longer valid ( as > > the other activities which remain on stack) . I would like to clear > > the whole activity stack and launch another activity to explain the > > current situation to user. > > > I could put the follow code on every activity "if(not valid state) > > finish() and launch a new activity with clear top flag enabled " but > > I don't think it is clever. Is there a better way to control which > > activity will be launched after application is killed ? > > > Tks, > > André > > -- 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

