From 9518478176cb011831e1bddccc4900e29b839f2b Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 14 Jan 2025 11:10:27 +0530 Subject: [PATCH] setup: Fix IllegalStateException on finish --- src/org/lineageos/setupwizard/BaseSetupWizardActivity.java | 5 ++++- src/org/lineageos/setupwizard/SubBaseActivity.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java b/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java index 8687d089..90dc0384 100644 --- a/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java +++ b/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java @@ -257,7 +257,10 @@ public abstract class BaseSetupWizardActivity extends AppCompatActivity implemen } setResult(resultCode, data); Intent intent = WizardManagerHelper.getNextIntent(getIntent(), resultCode, data); - mNextIntentResultLauncher.launch(intent); + // Ensure the ActivityResultLauncher is registered before using it + if (mNextIntentResultLauncher != null) { + mNextIntentResultLauncher.launch(intent); + } } /** Adorn the Intent with Setup Wizard-related extras. */ diff --git a/src/org/lineageos/setupwizard/SubBaseActivity.java b/src/org/lineageos/setupwizard/SubBaseActivity.java index fe6ab12f..706b6573 100644 --- a/src/org/lineageos/setupwizard/SubBaseActivity.java +++ b/src/org/lineageos/setupwizard/SubBaseActivity.java @@ -73,7 +73,10 @@ public abstract class SubBaseActivity extends BaseSetupWizardActivity { subactivityIntent.putExtra(EXTRA_WIZARD_BUNDLE, wizardBundle); } try { - mSubactivityResultLauncher.launch(subactivityIntent); + // Ensure the ActivityResultLauncher is registered before using it + if (mSubactivityResultLauncher != null) { + mSubactivityResultLauncher.launch(subactivityIntent); + } } catch (ActivityNotFoundException e) { Log.w(TAG, "activity not found; start next screen and finish; intent=" + intent); mIsSubactivityNotFound = true; -- GitLab