That is a very bad way of doing it. What if the user presses the HOME button? What if the user goes to a different activity using the notification bar? The camera button? What if it's a device that allows switching activities using a custom button?
Relying on a button press to detect the lifetime of your application is a major hack and bound to break in many ways. You might want to read the documentation for the Activity class to see how the lifetime of an application works. It goes in detail about what each stage does: onPause wants you to suspend your threads. onDestroy means your app will be gone for good if isFinishing() is set. If you want to handle the specific case of an orientation change, you can respond to onConfigurationChanged(). I would strongly advise against any kind of hacks circumventing those methods. What are you trying to do in your back button code? -Mike On Sep 17, 2:28 pm, Nanard <[email protected]> wrote: > I have founded ! Thanks > > I should not rely on onStop() nor onDestroy() to know when I quit my > Activity. > > The only safe way is : > > @Override > public boolean onKeyDown(int keyCode, KeyEvent event) { > > if (keyCode == KeyEvent.KEYCODE_BACK) { > ... do some cleaning here > } > return super.onKeyDown(keyCode, event); > } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

