-2

In my app, I have four activities Splash -> Activity A -> Login Activity -> Main-Activity. Now when user is authenticated, I wanna clear current task and launch a new task for Main-Activity. For this, I have tried the below code.

var intents = Intent(this@Login,MainActivity::class.java)
    intents.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK )
    startActivity(intents)
    finish()

So when i am in Main-Activity, hits the back button and launch the app again, it first shows (Splash-> Main-Activity) instead of showing Main-Activity directly. I also follow this link Clearing the Launcher Activity from the stack but nothing happened.Please tell me anyone what should i do to make it work..

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mattwalk
  • 139
  • 1
  • 3
  • 13

1 Answers1

0

Keep flag for user Logged in for first time. Check if user is logging in for first time. If user is logging in for first time,show splash screen and then Main activity but if user has logged in ,then don't show splash screen. Just start intent for Main Activity

  • yes it might be works but my question is when i'm setting intent flags to new task and clear task then why it's not working. why the stack still has Splash Screen activity. It should be clear but its not clearing.. – Mattwalk Jan 24 '18 at 16:10