Skip to content Skip to sidebar Skip to footer

Clearing The Launcher Activity From The Stack

In my app, I have activity A (Launcher/Main Activity) ,B,C. A launches B or C depending on if the user is authenticated. Now how do I remove A such that when the back button is pre

Solution 1:

I think you need to set

android:noHistory="true"

on A. You might also need to launch B/C with these Flags:

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);    

Finally, you can finish all activities under the current one in the task stack with the same affinity by calling:

finishAffinity()

For further information: Android: Clear the back stack

Post a Comment for "Clearing The Launcher Activity From The Stack"