Kill You Application

5 votes · 5 comments

If you want to completely kill your application, rather than just finish the activity then either of the above snippets will do.

Thanks to sammyF on #android for the second way, which is shorter but probably less of an official way to do it.

raw ·
copy
· download
/* Way one */ android.os.Process.killProcess(android.os.Process.myPid()) /* Way Two */ System.exit(0);
Add a comment

5 Comments

you will find core android developers on the google group deriding this sort of process murder. just use finish(). see here http://markmail.org/message/ni2vh4ckeqax7q5c#query:related%3Ani2vh4ckeqax7q5c+page:1+mid:ni2vh4ckeqax7q5c+state:results

Reply · June 23, 2009, 7:09 a.m.

You can use another way: ActivityManager.restartPackage(packageName);

That's way 3:)

Reply · July 29, 2009, 2:54 p.m.

How to kill others Application?

Reply · Sept. 25, 2009, 1:37 p.m.

"How to kill others Application?"

Answer: ActivityManager.restartPackage(packageName);

Reply · Sept. 28, 2009, 10:12 p.m.

Thanks for sharing!

Reply · March 26, 2011, 4:10 p.m.

DON'T KILL ME

Reply · June 9, 2011, 12:53 p.m.
Reply · Nov. 8, 2011, 5:46 a.m.