Prevent animation on activity start or stop


I was looking for a way to prevent the animation into and out of Activities. Here is what I found:

To prevent the default slide animation on Activity.finish() I found the following to work on 1.6. I am not sure what other versions it works on.
getWindow().setWindowAnimations(0);
For animation into a new activity for 1.6 is done the following:
int FLAG_ACTIVITY_NO_ANIMATION = 65536;
Intent intent = new Intent(your.class);
intent.addFlags(FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);

And for 2.0 and above, Intent.FLAG_ACTIVITY_NO_ANIMATION should be used.

Leave a Reply

Your email address will not be published. Required fields are marked *