0

I have a logout button in my activity. In my case the killProcess do what I want to do instead of the finish(), but is it a good idea to use killProcess? I have read that is better not to use killProcess but in some cases seems to be useful.

anna
  • 745
  • 2
  • 9
  • 30
  • 1
    Can you provide an example for such a case please? Can't get one from the top of my head. –  Sep 21 '11 at 00:59
  • I am using a timer to send periodically requests to a server(bad idea I know,but this is just a temporary solution). When I use finish() the client keep on sending requests but with killProcess not! I suppose that there would be another way to solve this but killProcess is an easy way! – anna Sep 21 '11 at 01:13
  • 2
    That's like launching a nuke at a fly. The timer can easily be stopped. Definitely not a use-case that justifies to harm androids whole automatic memory-/process-management. –  Sep 21 '11 at 01:15
  • Nothing to say. Thank you! :) – anna Sep 21 '11 at 01:29

1 Answers1

0

Calling killProcess stops the process immediately. There is no way for your app to prevent this or prepare for it. However, when you call finish you app is notified and is given a chance to release system resources, save states, etc. Using finish is the recommended and preferred way to shut things down. To use killProcess would be considered hackish and bad style.

If you are having problems with finish() closing the app fast enough you should consider overloading that method.

slayton
  • 20,123
  • 10
  • 60
  • 89