Example usage for android.content Intent FLAG_ACTIVITY_NO_ANIMATION

List of usage examples for android.content Intent FLAG_ACTIVITY_NO_ANIMATION

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_NO_ANIMATION.

Prototype

int FLAG_ACTIVITY_NO_ANIMATION

To view the source code for android.content Intent FLAG_ACTIVITY_NO_ANIMATION.

Click Source Link

Document

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

Usage

From source file:Main.java

public static void launchActivity(Context context, Class<?> activity) {
    Intent intent = new Intent(context, activity);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    context.startActivity(intent);/*from www  .  j  a v  a  2  s .co m*/
}

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 .  ja  va2  s  .  co m*/
    activity.overridePendingTransition(0, 0);
}

From source file:Main.java

public static void launchActivityForResult(Activity context, Class<?> activity, int requestCode) {
    Intent intent = new Intent(context, activity);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    context.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static void launchActivity(Context context, Class<?> activity, Bundle bundle) {
    Intent intent = new Intent(context, activity);
    intent.putExtras(bundle);//from ww  w .  j  a  v  a  2 s. c o m
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    context.startActivity(intent);
}

From source file:Main.java

public static boolean isAppInstalled(Context context, String desiredPackageName) {
    Intent intent = new Intent("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.LAUNCHER");

    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    List<ResolveInfo> resolveInfoList = context.getPackageManager().queryIntentActivities(intent, 0);

    for (ResolveInfo info : resolveInfoList) {
        if (info.activityInfo.packageName.equalsIgnoreCase(desiredPackageName)) {
            return true;
        }/*from   w  w  w. j a  va2s  .  c  o  m*/
    }
    return false;
}

From source file:Main.java

public static void restartClearActivity(Activity activity) {
    if (activity == null)
        return;//from ww  w . j  av a2s.c om
    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 restartClearActivityOutside(Activity activity) {
    if (activity == null)
        return;//  w w w  .  j a  v a 2  s . c om
    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:Main.java

public static void restartActivity(Activity activity) {

    if (activity == null)
        return;/* ww w .  ja  v  a 2s  .c  om*/

    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

/**
 * Restart the Activity//from  ww  w.  j av a 2s .  c o m
 *
 * @param activity
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void restartActivity(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    } else {
        Intent intent = activity.getIntent();
        activity.overridePendingTransition(0, 0);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        activity.finish();

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

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
 *///www . j a va 2s  .c  o  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);
    }
}