Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing an activity from the history stack

My app shows a signup activity the first time the user runs the app, looks like:

  1. ActivitySplashScreen (welcome to game, sign up for an account?)
  2. ActivitySplashScreenSignUp (great, fill in this info)
  3. ActivityGameMain (main game screen)

so the activities launch each other in exactly that order, when the user clicks through a button on each screen.

When the user goes from activity #2 to #3, is it possible to wipe #1 and #2 off the history stack completely? I'd like it so that if the user is at #3, and hits the back button, they just go to the homescreen, instead of back to the splash screen.

I think I can accomplish this with tasks (ie. start a new task on #3) but wanted to see if there was simpler method,

Thanks

like image 728
Mark Avatar asked Dec 14 '09 04:12

Mark


People also ask

How do I delete activity from stack?

The easiest way is to give the LoginActivity a “android:noHistory = true” attribute in the manifest file. That instructs Android to remove the given activity from the history stack thereby avoiding the aforementioned behavior altogether.

How do you delete Android activity history?

On your Android phone or tablet, go to myactivity.google.com. Above your activity, tap Delete . Tap All time. Delete.

How do you delete old activity?

startActivity(intent); It will totally clears all previous activity(s) and start new activity.

How do I start activity and clear back stack?

Declare Activity A as SingleTop by using [android:launchMode="singleTop"] in Android manifest. Now add the following flags while launching A from anywhere. It will clear the stack.


1 Answers

You can achieve this by setting the android:noHistory attribute to "true" in the relevant <activity> entries in your AndroidManifest.xml file. For example:

<activity     android:name=".AnyActivity"     android:noHistory="true" /> 
like image 172
Aitor Gómez Avatar answered Sep 24 '22 12:09

Aitor Gómez