0

how can I avoid adding an activity to a backstack.

This is how I start an activity

    startActivity(
        StripeConnectActivity.createIntent(
            context = baseContext,
            paymentSetupState = paymentSetupState,
            setupFlowType = SetupFlowType.STANDARD
        )
    )
a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
BRDroid
  • 3,920
  • 8
  • 65
  • 143
  • Instead of not adding to the backstack you can finish it when moving on to the next activity. Please describe the scenario to get a better answer.. – gioravered Mar 01 '22 at 09:42

2 Answers2

2

Simply follow up your call to startActivity() with a finish() call to close the current activity so it won't be in the back stack.

startActivity(
    StripeConnectActivity.createIntent(
        context = baseContext,
        paymentSetupState = paymentSetupState,
        setupFlowType = SetupFlowType.STANDARD
    )
)
finish()
Tenfour04
  • 83,111
  • 11
  • 94
  • 154
0

Try to set flags to the intent

intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK

or you can modify

    override fun onBackPressed() {
    super.onBackPressed()
    }
AhmetAcikalin
  • 328
  • 2
  • 7