EGHDK
EGHDK

Reputation: 18130

Trying to stop animation when starting a new activity in android

There's a ton of questions on SO that ask about stopping the animation when starting a new activity and I'm just having no luck. Am I doing something wrong that is blatantly obvious? Thanks in advance.

public void onClick (View view) {
Intent about = new Intent(this, about.class);
        about.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

        startActivity(about);
        overridePendingTransition(0, 0);
}

Upvotes: 0

Views: 136

Answers (1)

Hemant G
Hemant G

Reputation: 653

You seem to be missing the setAction(Intent.ACTION_VIEW);.

This is when you start a new activity.

Intent aboutIntent = new Intent(this, about.class); aboutIntent.setAction(Intent.ACTION_VIEW); aboutIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(aboutIntent); overridePendingTransition(0, 0);

When you press back button, you will be still shown animation. To remove this animation, you have to add overridePendingTransition(0, 0); to onPause method of the activity on which you pressed back button.

Upvotes: 1

Related Questions