> So in my case, I should listen for onDestroy() and terminate the > thread there?
Well, that depends. They're aren't many reasons for you to be executing in your Activity when it is not visible. You should stop all threads when you receive onPause(). If you have background processing, this should be done in a Service, and perhaps a remote one so that the process hosting your Activity can be killed, and leave your Service to do whatever it needs to do. Cheers, Justin Android Team @ Google On Oct 31, 12:02 pm, Mark Wyszomierski <[EMAIL PROTECTED]> wrote: > Hi Romain Guy, > > Ok so we never put an "exit app" interface for users - what happens in > this case: > > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > if (m_thread == null) { > m_thread = new Thread() { > public void run() { > while (m_run) { > Log.d("*", "hello..."); > Thread.sleep(5000); > } > } > }; > m_thread.start(); > } > > } > > This app just creates a background thread which runs forever. When I > hit the back button etc, I can see that the thread is still alive even > though the Activity is no longer visible. If I start the app again, I > can see that m_thread is already initialized - > > So in my case, I should listen for onDestroy() and terminate the > thread there? > > Thank you > > On Oct 31, 2:57 pm, Romain Guy <[EMAIL PROTECTED]> wrote: > > > The user doesn't, the system handles this automatically. That's what > > the activity lifecycle (especially onPause/onStop/onDestroy) is for. > > No matter what you do, do not put a "quit" or "exit" application > > button. It is useless with Android's application model. This is also > > contrary to how core applications work. > > > Note that when the user presses Back, the Activity is destroyed. > > > On Fri, Oct 31, 2008 at 11:14 AM, Mark Wyszomierski <[EMAIL PROTECTED]> > > wrote: > > > > Hi, > > > > When our application is started, our main Activity comes alive. In the > > > emulator, how do you "kill" the application? It seems my Activity is > > > living forever. Does the user have a choice to kill the application > > > unless we put a menu option in to kill it? If no such option exists, > > > how does the user terminate the application? > > > > Thanks > > > -- > > Romain Guywww.curious-creature.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---