Finish multiple activities on an authentication flow android

by Fidriyanto Rizkillah   Last Updated July 12, 2019 14:26 PM - source

So I have an app that has authentication on it here is the flow:

LoginPage -> Register -> RegisterConfirmation -> OTP Code -> EmailVerification -> Homepage

I want that if the user is already on OTP Code or Email Verification and he pressed the back button, the user will get straight to Homepage because he already got the AccessToken since RegisterConfirmation.

Here's the flow I want to look like: flow

How can I possible does this, I've already done some research but all I got is only how to finish only one activity (parent)?

Answers 2

When the user presses Back button do the below on onBackPressed() method. This might solve your problem. What it does is it clears the previous task and creates a new task
with the only activity in stack.

val intent = Intent(this,{
Birju Vachhani
Birju Vachhani
July 11, 2019 19:04 PM

Don't let the user go to OTP Code and check in registerconfirmation activity if the user already obtained his token access.

If you try to start an activity say A and you are in the current activity say D, you can use this with your intent :


To clear top activities (B,C,D)


You can keep the current instance of your activity using

Sam Khedjam
Sam Khedjam
July 11, 2019 19:10 PM

Related Questions

Pass form data to the called activity

Updated June 04, 2017 06:26 AM