John Yes, you are right. Pressing Home does call just onStop; while pressing Back calls onDestroy.
Btw, how do you ensure that the service keeps running and doing its job even when the phone goes to sleep (power save mode)? I added PowerManager = pm = (PowerManager) getSystemService(Context.POWER_SERVICE); WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyService"); wl.acquire(); but it didn't seem to help On Wed, Sep 9, 2009 at 8:26 PM, John P. <[email protected]> wrote: > > It is true that when the Back button is pressed, onDestroy() is > called. But hitting the Home button invokes the activity's onStop() > for me. Now, it is true that if Android determines it needs memory, > it may then invoke onDestroy() on the stopped activity. > > It sounds like if you want your activity to do something while > "minimized" (i.e. in the background with no user interaction), then > this logic should really be in your service. > > I wrote a program where a service continuously does some processing > while keeping its state. I have an activity that binds to the > service, gets the state, and appropriately rehydrates its own state > accordingly. Everytime the activity pauses, it unbinds. Everytime it > resumes, it rebinds. All the "continuous" processing is done on the > service, and the activity gives the user a chance to modify the data. > But when the activity is dead, the service continues on until I > explicitly kill it through the said activity. > > On Sep 9, 10:01 pm, Jason <[email protected]> wrote: > > How do I achieve the effect of 'minimizing' a UI activity? I have a UI > > activity that gets destroyed each time I click the Home, phone etc. keys > on > > the phone. I would like the UI activity to be sent to the background; > since > > it is bound to a service and processing the data returned by the service > > continuously. Clicking on the app ends up calling onCreate, onStart > again. I > > would like to restart (onResume) instead. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" 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-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

