如何关闭在android的整个应用程序应用程序、android

2023-09-12 06:09:25 作者:往事埋风中

可能重复:   Android:如何杀死所有它的活动的应用程序?

我试着用完成()

但它只是关闭present活动不是整个应用程序。 作为另一个活动正在运行隐藏它表明,当我完成了上述活动。

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

}

推荐答案

使用此行的code:

System.exit(1);

整数 1仅仅是一个返回code。

The integer 1 is just a return code.

修改 这是我第一次开始android开发回答:请不要使用它。你可以尝试添加退出按钮,Android应用程序。

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.