Reload / Restart an Activity in Android

Restarting an activity is pretty straight forward if your app supports HoneyComb and above. Just use Activiy.recreate. However, when supporting lower api versions you need something equivalent to Activity.recreate. I found this method to be useful. If you need to restart an activity from more than one activty it can be put in a utility class.

Current Activity instance will go through its lifecycle to onDestroy() and a new instance then created after it.
  public static final void recreateActivityCompat(final Activity a) {
    } else {
      final Intent intent = a.getIntent();
      a.overridePendingTransition(0, 0);
      a.overridePendingTransition(0, 0);

3 Responses

  1. Srikanth says:

    Thanks a lot……

  2. Tajiri says:

    This is awesome, and it works well.

  3. Morpheo says:

    this works… thank you so much!