How to restart android Activty?

Here is how to restart an activity in Android.


public void reload() {

    Intent intent = getIntent();
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();

    overridePendingTransition(0, 0);
    startActivity(intent);
}

But Since API level 11, you can use recreate() method. The recreate() method acts just like a configuration change, so your onSaveInstanceState() and onRestoreInstanceState() methods are also called, if applicable.

Comments

Popular posts from this blog

Fatal: LoadModule: error loading module 'mod_sql_mysql.c'

Regular Expression Route Constraints And Route Names in Laravel 5.4