From 2d1c48324a156c5b22891ec46f8d0e7702db19f8 Mon Sep 17 00:00:00 2001 From: DjBushido Date: Mon, 24 Feb 2014 22:30:44 -0500 Subject: [PATCH] Kill the application when the Exit button of the ResultActivity is pressed. --- HW3/src/com/uncc/hw3/MainActivity.java | 4 ++++ HW3/src/com/uncc/hw3/ResultActivity.java | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/HW3/src/com/uncc/hw3/MainActivity.java b/HW3/src/com/uncc/hw3/MainActivity.java index 15237e0..69b9193 100644 --- a/HW3/src/com/uncc/hw3/MainActivity.java +++ b/HW3/src/com/uncc/hw3/MainActivity.java @@ -38,6 +38,10 @@ public class MainActivity extends Activity super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + // If the result activity calls us with an EXIT in the extras, quit. + if (getIntent().getBooleanExtra("EXIT", false)) + finish(); + newGame((View)findViewById(R.id.LinearLayout1)); focusImages.get(focusIndex).show(); } diff --git a/HW3/src/com/uncc/hw3/ResultActivity.java b/HW3/src/com/uncc/hw3/ResultActivity.java index 246582d..21e9d7e 100644 --- a/HW3/src/com/uncc/hw3/ResultActivity.java +++ b/HW3/src/com/uncc/hw3/ResultActivity.java @@ -55,8 +55,11 @@ public class ResultActivity extends Activity { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } - else if (v.getId() == R.id.btnExit) - finish(); + else if (v.getId() == R.id.btnExit){ + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.putExtra("EXIT", true); + startActivity(intent); + } } }