2011-10-22 62 views
0

我的應用程序中有七項活動。我在第一次活動中有退出按鈕。當我第一次點擊退出按鈕時,它運行正常......但是當我在第二,第三......活動,並直接到第一個活動,然後退出按鈕帶我在以前活動.....如何關閉應用程序

Button Exit = (Button) findViewById(R.id.close); 
    Exit.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 

      finish(); 
      System.exit(1); 

     } 

    }); 
+0

可能重複的[退出應用程序 - 是皺眉?](http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon) – adatapost

回答

0

Android的設計方式是不需要關閉應用程序。如果你想讓用戶進入主屏幕,你可以創建一個顯示主屏幕的意圖。像這樣的:intent.addCategory(Intent.CATEGORY_HOME);。無需System.exit(1)

+0

我可以選擇移動主屏幕.........但我想退出應用程序? –

+1

如果你真的想停止進程出於某種原因,你應該檢查killProcess: http://developer.android.com/reference/android/os/Process.html#killProcess(int)。 'android.os.Process.killProcess(android.os.Process.myPid());' – Lycha