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);

5 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!

  4. BestFredrick says:

    I see you don’t monetize your website, don’t waste
    your traffic, you can earn additional bucks every month because
    you’ve got hi quality content. If you want to know
    how to make extra money, search for: Ercannou’s essential adsense alternative

  5. LinneaBold says:

    I have checked your website and i’ve found some duplicate content, that’s why you don’t rank high in google’s search results, but there is a tool that can help you to create 100% unique articles, search for; SSundee advices unlimited content
    for your blog

Leave a Reply

Commenting Tips

  • These tags can be used (optional): <a href="" title="" rel=""> <abbr title=""> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strong> <pre>
  • When posting code, please use <code>your code here</code> or <pre><code>your code here</code></pre> for larger blocks.
    Escape < and > with &lt; and &gt;