-1

Possible Duplicate:
Android: How to kill an application with all it's activities?

I tried with finish().

But it just close the present activity not whole application. as the another activity is running hide it shows when i finish the above activity..

CODE :

public class third extends  Activity{

Button btn_back, btn_finish;
Intent intent2;
Bundle b1;


 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.third);


        intent2 = getIntent();
        b1=intent2.getExtras();
        String spin = b1.getString("name");
        String gender = b1.getString("gender");



        btn_back = (Button) findViewById(R.id.button1);
        btn_finish = (Button)   findViewById(R.id.button2);
        Toast.makeText(third.this, spin + "" + gender , Toast.LENGTH_SHORT).show();

        btn_back.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                intent2 = new Intent (third.this,second.class);
                startActivity(intent2);
            }
        });

        btn_finish.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                finish();
            }
        });
 }

}

Community
  • 1
  • 1
SilentKiller
  • 6,944
  • 6
  • 40
  • 75
  • You'll have to set a boolean flag within a class extending application, then within onPause of each activity if this flag is set call finish() for that activity (i.e. this will cascade finish() your whole app); – Blundell Aug 02 '11 at 12:09
  • 1
    Please learn to spend at least 10 minutes researching for yourself before submitting a question, this question has been asked many, many times before – Marmoy Aug 02 '11 at 12:14
  • System.exit(0) is not working... – SilentKiller Aug 02 '11 at 12:14
  • 1
    When you write a question, SO will show you a list of similar questions asked before. In your case any of those suggestions would have answered your question – Marmoy Aug 02 '11 at 12:16

1 Answers1

4

Use this line of code:

System.exit(1);

The integer 1 is just a return code.

EDIT This was answered when I first started android development: Please do not use it. You could try Adding an Exit button to Android Application.

Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106