Example usage for android.app Activity overridePendingTransition

List of usage examples for android.app Activity overridePendingTransition

Introduction

In this page you can find the example usage for android.app Activity overridePendingTransition.

Prototype

public void overridePendingTransition(int enterAnim, int exitAnim) 

Source Link

Document

Call immediately after one of the flavors of #startActivity(Intent) or #finish to specify an explicit transition animation to perform next.

Usage

From source file:Main.java

public static void startActivityClearTask(Activity activity, Class<? extends Activity> clazz) {
    Intent intent = new Intent(activity, clazz);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);/*from   ww w .j  a  va 2 s  .c om*/
    activity.overridePendingTransition(0, 0);
}

From source file:Main.java

public static void IntentDIY(Activity activity, Class<?> classes, Map<String, String> paramMap, int enterAnim,
        int exitAnim) {
    intent = new Intent(activity, classes);
    organizeAndStart(activity, classes, paramMap);
    if (enterAnim != 0 && exitAnim != 0) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }/*from  w  w w  .  j a  v  a2 s .  co  m*/
}

From source file:com.github.dfa.diaspora_android.util.Helpers.java

public static void animateToActivity(Activity from, Class to, boolean finishFromActivity) {
    Intent intent = new Intent(from, to);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    from.startActivity(intent);/*from   w  w  w . j ava2 s.  co m*/
    from.overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    if (finishFromActivity) {
        from.finish();
    }
}

From source file:Main.java

/**
 * Restarts activity, from http://stackoverflow.com/questions/1397361/how-do-i-restart-an-android-activity
 * @param activity the activity to restart
 *///from ww  w .  j  ava 2 s  .co  m
@TargetApi(11)
public static void restartActivity(Activity activity) {
    if (Build.VERSION.SDK_INT >= 11) {
        activity.recreate();
    } else {
        Intent intent = activity.getIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        activity.finish();
        activity.overridePendingTransition(0, 0);

        activity.startActivity(intent);
        activity.overridePendingTransition(0, 0);
    }
}

From source file:Main.java

public static void restartClearActivity(Activity activity) {
    if (activity == null)
        return;/*from  w w  w  .j av a  2  s .c  o m*/
    Context ctx = activity.getApplicationContext();
    Intent intent;
    intent = activity.getIntent();
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION);

    activity.finish();
    activity.overridePendingTransition(0, 0);

    ctx.startActivity(intent);
    activity.overridePendingTransition(0, 0);

}

From source file:Main.java

public static void recreate(@NonNull Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();//from  ww w. j  a v a  2 s .  c om
    } else {
        Intent intent = activity.getIntent();
        intent.setClass(activity, activity.getClass());
        activity.startActivity(intent);
        activity.finish();
        activity.overridePendingTransition(0, 0);
    }
}

From source file:Main.java

public static void restartClearActivityOutside(Activity activity) {
    if (activity == null)
        return;//  ww  w.j a v a2s .  co  m
    Context ctx = activity.getApplicationContext();
    Intent intent;
    intent = activity.getIntent();
    intent.addFlags(
            Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);

    activity.finish();
    activity.overridePendingTransition(0, 0);

    ctx.startActivity(intent);
    activity.overridePendingTransition(0, 0);

}

From source file:org.linphone.compatibility.ApiFivePlus.java

public static void overridePendingTransition(Activity activity, int idAnimIn, int idAnimOut) {
    activity.overridePendingTransition(idAnimIn, idAnimOut);
}

From source file:Main.java

public static void restartActivity(Activity activity) {

    if (activity == null)
        return;/*w ww .j  av a 2s . c o m*/

    if (Build.VERSION.SDK_INT >= 11) {
        activity.recreate();
    } else {
        Intent intent;
        intent = activity.getIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.finish();
        activity.overridePendingTransition(0, 0);
        activity.startActivity(intent);
        activity.overridePendingTransition(0, 0);
    }

}

From source file:Main.java

public static void openActivity(Activity activity, Intent intent, int requestCode, int enterAnim,
        int exitAnim) {
    if (null == activity)
        return;/*from   w w  w  .j av  a2s .co  m*/

    if (requestCode < 0) {
        activity.startActivity(intent);
    } else {
        activity.startActivityForResult(intent, requestCode);
    }

    if (enterAnim > 0 && exitAnim > 0) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}