1

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.

RAAAAM
  • 3,378
  • 19
  • 59
  • 108

2 Answers2

1

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.

Footcow
  • 38
  • 4
0

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

Community
  • 1
  • 1
Jaydeep Khamar
  • 5,975
  • 3
  • 32
  • 30