Home > other >  How can I stop activity being added to backstack
How can I stop activity being added to backstack

Time:03-02

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
        )
    )

CodePudding user response:

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()

CodePudding user response:

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()
    }
  • Related