Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to destroy android application and clear from memory?

Tags:

android

I tried System.Exit(0), but is not that i need;

I'm trying to safely destroy android application and clear it from memory,
can i make a button to exit android application and clear all application from memory ?

like image 268
user2515339 Avatar asked Oct 04 '22 17:10

user2515339


1 Answers

Calling System.exit() is a bad idea. You can simply call finish() on all the activities you need to kill. Here's a good solution to do this: https://stackoverflow.com/a/5453228/1369222

The basic idea is to add a broadcast receiver to every activity of your app that will finish itself when a particular "kill activities" intent is fired.

like image 114
Anup Cowkur Avatar answered Oct 07 '22 19:10

Anup Cowkur