How to force close app such as system close on Android

brian picture brian · Jan 17, 2013 · Viewed 7.7k times · Source

I want to force close my app as Android system.
Such as select below step on system.

"Setting" -> "Apps" -> "my app name" -> "Force stop"  

I want to implement the same behavior by code.
How can I do it?

Answer

TNR picture TNR · Jan 17, 2013

You can write below line of code to kill your App process. This is what the code runs when you click the Force Stop in

Settings --> Manage Applications

android.os.Process.killProcess(android.os.Process.myPid());