Refresh Current Activity without Delay

33,067

Solution 1

You can try this:

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

this reload's your activity without animation.

Solution 2

Call this method when you need to refresh your activity.

recreate();

Solution 3

This is in Kotlin, might work for you:

startActivity(intent)
overridePendingTransition(0,0)
finish()
overridePendingTransition(0,0)

Solution 4

This code may work

Intent intent = getIntent();
finish();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
Share:
33,067
YouKnowbetter
Author by

YouKnowbetter

Updated on July 05, 2020

Comments

  • YouKnowbetter
    YouKnowbetter almost 4 years

    I am new to android development.So I want to refresh the current activity when Radio button clicked.When I clicked the radio button I want to change the language and refresh the current Activity without any delay.Now I click the button the current layout gone and open new one.But it takes some time.Anyone can see there is new layout coming. This is my code

    Intent intent = getIntent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();
    startActivity(intent);
    
  • YouKnowbetter
    YouKnowbetter almost 11 years
    sory i didn't get you.you means without start new Activity when click radio button set to oncreate null.
  • Hardik Joshi
    Hardik Joshi almost 11 years
    It will reload current activity.
  • Hardik Joshi
    Hardik Joshi almost 11 years
    @YouKnowbetter Is it not call onCreate() ?
  • YouKnowbetter
    YouKnowbetter almost 11 years
    sry.can you tell me how to do that.i am confusing.
  • Hardik Joshi
    Hardik Joshi almost 11 years
    @YouKnowbetter What you get after placing onCreate(null) ?
  • YouKnowbetter
    YouKnowbetter almost 11 years
    Then Application crashed.