Example usage for android.app Activity recreate

List of usage examples for android.app Activity recreate

Introduction

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

Prototype

public void recreate() 

Source Link

Document

Cause this Activity to be recreated with a new instance.

Usage

From source file:Main.java

public static void restartActivity(Activity activity) {
    activity.recreate();
}

From source file:Main.java

@TargetApi(11)
public static void recreate(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    }//from w ww . j a  va2s  .  c  om
}

From source file:Main.java

public static void restart(final @NonNull Activity activity) {
    if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    } else {/*from w  ww . j  ava 2s  .  c  o m*/
        final Intent intent = activity.getIntent();
        activity.finish();
        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 va2 s  .com*/
@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 recreate(@NonNull Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    } else {/*from w w  w  . j ava  2s  .  co  m*/
        Intent intent = activity.getIntent();
        intent.setClass(activity, activity.getClass());
        activity.startActivity(intent);
        activity.finish();
        activity.overridePendingTransition(0, 0);
    }
}

From source file:Main.java

/**
 * Restart the Activity//from  w w  w . ja v  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

public static void restartActivity(Activity activity) {

    if (activity == null)
        return;//from w ww  .  ja v  a  2  s.  co  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 restartActivityOutside(Activity activity) {

    if (activity == null)
        return;//from  w w  w  .  j  a v  a 2s.  c  om

    if (Build.VERSION.SDK_INT >= 11) {
        activity.recreate();
    } else {
        restartClearActivityOutside(activity);
    }

}

From source file:io.github.hidroh.materialistic.AppUtils.java

public static void restart(Activity activity, boolean transition) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    } else {//from   www . j a v  a  2  s .c  o  m
        activity.finish();
        if (transition) {
            activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        }
        activity.startActivity(activity.getIntent());
    }
}

From source file:com.g11x.checklistapp.NavigationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    PreferredLanguageSupport.applyPreferredLanguage(this);
    final Activity thisActivity = NavigationActivity.this;
    baseLanguageChangeListener = new AppPreferences.LanguageChangeListener(NavigationActivity.this) {
        @Override/*from   ww  w  .  j  a v  a  2 s  .  c  om*/
        public void onChanged(String newValue) {
            thisActivity.recreate();
        }
    };
}