Android Activity Start restartPC(final Activity activity)

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

Description

Restart the activity smoothly

Parameter

Parameter Description
activity a parameter

Declaration

public static void restartPC(final Activity activity) 

Method Source Code

//package com.java2s;

import android.app.Activity;

public class Main {
    /**//from   w  w  w  . ja  va  2 s  .  co m
     * Restart the activity smoothly
     * @param activity
     */
    public static void restartPC(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. restartActivity(final Activity activity)
  6. startActivity(Context context, Class activity)
  7. startNewActivity(Class target, final Activity activity)
  8. prepare(Activity activity, int id, int width)