Start a new activity with no transition animation in android 1.6

19,625

Solution 1

Use this: getWindow().setWindowAnimations(0); within the Activity that is starting.

Solution 2

On the newer versions, you want to override the transition with 0,0 shortly after you start the activity:

Intent i = new Intent(this, YourNewActivity.class); 
startActivity(i);
overridePendingTransition(0,0);

I tried this on 2.1 and 4.0.3, it worked for me. =)

I found it in the docs here

Solution 3

This solution worked for me (Android 2.2):

Intent intent = new Intent(getContext(), YourClass.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
getContext().startActivity(intent);

Solution 4

FYI, I'm on 4.4.2 and these are the only things I found that work:

To prevent the opening animation: in the launching activity's onCreate(), add overridePendingTransition(0,0).

To prevent the closing animation: after finish(), immediately call overridePendingTransition(0,0).

These DON'T work (at least not on my 4.4.2 build): (1) calling getWindow().setWindowAnimations(0) in onCreate() (passing in a non-zero number DOES work, but that's an ugly hack since it's expecting a resId), and (2) calling overridePendingTransition(0,0) immediately after startActivity() -- animation is still present.

Share:
19,625
Matt Colliss
Author by

Matt Colliss

Updated on June 06, 2022

Comments

  • Matt Colliss
    Matt Colliss almost 2 years

    I am aware that from API level 5 it is possible to specify a flag in the intent to prevent the normal animation being applied when I start a new activity:

    myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    

    However, my question is: is there a way to achieve the same thing in an app supporting android 1.6?