2

I am a newbie in android.

As far as I am concern, when we start activity using intent like this :

Intent masuk=new Intent(getApplicationContext(),Destination.class);
startActivity(masuk);

It will create an effect (whatsoever it called). In my program i want to make that effect disappear. Can you tell me the right way to do it ?

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
studentknight
  • 143
  • 1
  • 3
  • 9

3 Answers3

3

You can use intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

Doc says -

public static final int FLAG_ACTIVITY_NO_ANIMATION

If set in an Intent passed to Context.startActivity(), this flag will prevent the system from applying an activity transition animation to go to the next activity state.

This doesn't mean an animation will never run -- if another activity change happens that doesn't specify this flag before the activity started here is displayed, then that transition will be used. This flag can be put to good use when you are going to do a series of activity operations but the animation seen by the user shouldn't be driven by the first activity change but rather a later one.

So simply do,

 Intent masuk=new Intent(getApplicationContext(),Destination.class);
 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
 startActivity(masuk);
Atul O Holic
  • 6,692
  • 4
  • 39
  • 74
2

Call this Activity method after your startActivity();

overridePendingTransition(0, 0);

The app will move in the next Activity without any transition

simoneL
  • 602
  • 1
  • 7
  • 23
1

If you want to remove animations for all Actvities transitions, rather than calling a line of code for each change, you can set it in your app theme :

<style name="AppBaseTheme" parent="android:Theme.Light">
    <item name="android:windowAnimationStyle">@null</item>
</style>

Then set the theme in your Manifest :

<application
    android:theme="@style/AppBaseTheme" >
    ...
</application>
2Dee
  • 8,609
  • 7
  • 42
  • 53