This discussion (in the comments) raised an interesting question :
What is the result of calling exit in an Android app (with regards to the android life-cycle) and can that damage the OS ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Android documentation for System.exit() says that it “Causes the VM to stop running and the program to exit.” I just tried it and it seems to kill the process for the app that called System.exit().
In the Android Developers thread named Activity.finish() x System.exit, someone corroborates that “System.exit() kills your entire process.”
Dianne Hackborn aka hackbod goes further “To be clear: using System.exit() is strongly recommended against, and can cause some poor interactions with the system. Please don’t design your app to need it.”
It should not damage the OS. Android will just let your app kill its process, not any other process on the system. It will keep the rest of the system running while your app ends.
I also verified this by running two applications and making one of them call System.exit(). The other was unaffected.