Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I kill an entire application on Android? [duplicate]

Possible Duplicate:
Android: How to kill an application with all its activities?

I am looking for a way to kill an entire application (e.g. shut down the process) in case my app crashes. The reason I want to do this is because a lot of my runtime data is stored in a static class, and so when the app crashes, this class is killed.

I have seen related questions about the Android philosophy (e.g. about not killing an app etc.), but for now I just need to kill my application. How can I do this?

My app has multiple activities and I tried the following. All it does is restore the previous activity.

System.exit(0)


 ActivityManager servMng
 servMng = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
 servMng.killBackgroundProcesses(<my package name>);


android.os.Process.sendSignal(android.os.Process.myPid(),
android.os.Process.SIGNAL_KILL);

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

like image 434
user510164 Avatar asked Jan 28 '26 23:01

user510164


1 Answers

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

Credit to @Thirumal Also possible duplicate How to kill an application with all its activities?

like image 104
YankeeWhiskey Avatar answered Jan 30 '26 13:01

YankeeWhiskey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!