如何彻底关闭Android应用程序

问题描述:

我创建了一个注销选项的Andr​​oid应用程序在 onCreateOptionsMenu 。在注销完美的作品,但是当我preSS后退按钮再需要我的previous活动,而当它得到一个空值重定向到登录界面。现在我的登录屏幕频频出现。我要彻底关闭应用程序,当我preSS后退按钮,但不知道怎么办。

I created an android application with a logout option in onCreateOptionsMenu. The Logout works perfectly but when I press the back button again it takes me to the previous activity, and when it gets a null value it redirects to login screen. Now my login screen appears again and again. I want to close the app completely when I press the back button but don't know how.

下面是我的code来处理后退按钮preSS在登录屏幕:

Here is my code to handle the back button press in the login screen:

@Override
public void onBackPressed() {
    new AlertDialog.Builder(this)
        .setTitle("BidNEMO")
        .setMessage("Are you sure you want to exit?")
        .setNegativeButton(android.R.string.no, null)
        .setPositiveButton(android.R.string.yes, new OnClickListener() {
         public void onClick(DialogInterface arg0, int arg1) {
         Main.super.onBackPressed();
         finish();
         }
         }).create().show();
     }

请帮忙guyss ..

please help guyss..

退出按钮上点击使用这个应用code:

To Quit Application on Button click use this code :

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

试试看。

要杀死完整的应用程序,并从删除它运行应用程序列表中杀掉通过 PID (其讨厌的应用程序)......之前使用上述code此行。

To kill the complete app and remove it from Runningapp list kill the app through its pid(its nasty)... use this lines before above code.

int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);