Skip to content Skip to sidebar Skip to footer

How To Shutdown An Android Application?

How to shutdown an android application? I don't find a shutdown command to application object. I want to shutdown and restart in case of some critical error.

Solution 1:

If there is some kind of "critical error", then you should should deal with it in your code rather then trying to restart the application.

You cannot shutdown an application in Android, however once all of your Activities are closed (which you can programatically do with the Activity.finish() method), then your application is considered to be closed.

Solution 2:

You don't need to shutdown an application, Android takes care of this.

The application is on the background and she is "freezed". If the system, or another application needs memory or CPU, Android will choose a background application to stop.

But everything is automatic. It's the Android's power !

Solution 3:

Here's a more in depth answer about quitting applications: Is quitting an application frowned upon?

Agree with elevine on handling errors...either deal with the error and get the user back to an acceptable state or let the app force close.

Solution 4:

To shutdown an activity you can use like told by other with finish(). If you want to force to terminate your app including all threads and the Application class you can use System.exit(), but that had some bad favior which I forgot...

Solution 5:

To terminate an activity, call finish(). To restart it, just call the intent again.

Post a Comment for "How To Shutdown An Android Application?"