Android Activity Start restartActivity(final Activity activity)

Here you can find the source of restartActivity(final Activity activity)

Description

Restart the activity smoothly

Parameter

Parameter Description
activity The activity to restart

Declaration

public static void restartActivity(final Activity activity) 

Method Source Code

//package com.java2s;
import android.app.Activity;

public class Main {
    /**/* w  w  w .  j av a  2s. c  om*/
     * Restart the activity smoothly
     *
     * @param activity The activity to restart
     */
    public static void restartActivity(final Activity activity) {
        if (activity == null)
            return;
        final int enter_anim = android.R.anim.fade_in;
        final int exit_anim = android.R.anim.fade_out;
        activity.overridePendingTransition(enter_anim, exit_anim);
        activity.finish();
        activity.overridePendingTransition(enter_anim, exit_anim);
        activity.startActivity(activity.getIntent());
    }
}

Related

  1. goToActivity(Context currentActivity, Class newClass)
  2. goToActivity(Context currentActivity, Class newClass, List extras)
  3. openActivity(Context packageContext, int flags, Map pairs, boolean closeCurrentContext, Class activity)
  4. startApkActivity(final Context ctx, String packageName)
  5. restartPC(final Activity activity)
  6. startActivity(Context context, Class activity)
  7. startNewActivity(Class target, final Activity activity)
  8. prepare(Activity activity, int id, int width)