From 9e3b7a75b234313c62dcf60931172530df478bf8 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Fri, 29 Oct 2021 21:20:04 +0530 Subject: [PATCH] Use `finishAffinity` instead of `finishAndRemoveTask` The method used to finish (`finishAndRemoveTask`) an activity prior to going back to `MainActivity` or restarting the process led to the process prematurely exiting entirely and would result in it not being restarted or another activity not being launched. This has now been fixed by utilizing `finishAffinity` in its place which correctly only ends the activities with the same affinity as the caller. --- app/src/main/java/emu/skyline/EmulationActivity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/emu/skyline/EmulationActivity.kt b/app/src/main/java/emu/skyline/EmulationActivity.kt index 677b17ff..29f3b7f7 100644 --- a/app/src/main/java/emu/skyline/EmulationActivity.kt +++ b/app/src/main/java/emu/skyline/EmulationActivity.kt @@ -55,7 +55,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo private var shouldFinish : Boolean = true /** - * If the activity should return to [MainActivity] or just call [finishAndRemoveTask] + * If the activity should return to [MainActivity] or just call [finishAffinity] */ var returnToMain : Boolean = false @@ -183,7 +183,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo shouldFinish = false if (returnToMain) startActivity(Intent(applicationContext, MainActivity::class.java).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) - finishAndRemoveTask() + finishAffinity() } } } @@ -199,7 +199,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo emulationThread!!.join(250) if (emulationThread!!.isAlive) { - finishAndRemoveTask() + finishAffinity() startActivity(intent) Runtime.getRuntime().exit(0) }