Reputation: 3380
Is there any possibilities to force stop the android application through program. previously i used finish(); method, but by doing this i can only quit the current activity and place back into existing or previous activity. i want to kill or force close the application, is this possible to do in android application. pls guide me to do this..Thanks in advance.
Upvotes: 1
Views: 2578
Reputation: 5985
May be this can be helpful in getting your answer How to close Android application?
I got some code..may be this is helpful to you
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
call this on your button's click event,It'll exit the application and yes..before you exit.just call System.gc()..I know it's just a warning.but it may be helpful in releasing some memory
Upvotes: 0
Reputation: 38
Using System.exit(0); is not recommanded but works.
In fact it's better to do something like : System.gc(); finish();
This will ask the system garbage to start cleaning clean, then finishing properly the apps.
Upvotes: 1