如何关闭在android的整个应用程序 [英] how to close whole application in android

查看:108
本文介绍了如何关闭在android的整个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/3105673/android-how-to-kill-an-application-with-all-its-activities">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.

这篇关于如何关闭在android的整个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆