0

I am developing one application. In that application I want to put Exit button. By clicking Exit Button I want to exit from application.

I used the following code:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();

It exit the application but not stop all activities which are running in that application.

Please give me some suggestion to solve this problem.

Adinia
  • 3,722
  • 5
  • 40
  • 58
dilipkaklotar
  • 1,469
  • 3
  • 20
  • 28
  • possible duplicate of [Quitting an application - is that frowned upon?](http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon) – Konstantin Burov Mar 23 '11 at 08:47

2 Answers2

2

This question was discussed many times already. You shouldn't make any "exit" buttons in your application. That's against Android nature and best practices. Look at Is quitting an application frowned upon? for wider discussion.

Community
  • 1
  • 1
Konstantin Burov
  • 68,980
  • 16
  • 115
  • 93
0

try this

system.exit(0);
Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125
Android
  • 8,995
  • 9
  • 67
  • 108