开发者

how to close whole application in android [duplicate]

This question already has answers here: Closed 11 years ago.

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();
            }
        });
 }

}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜