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);
![YouKnowbetter](https://i.stack.imgur.com/2FWP1.jpg?s=256&g=1)
Author by
YouKnowbetter
Updated on July 05, 2020Comments
-
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 almost 11 yearssory i didn't get you.you means without start new Activity when click radio button set to oncreate null.
-
Hardik Joshi almost 11 yearsIt will reload current activity.
-
Hardik Joshi almost 11 years@YouKnowbetter Is it not call onCreate() ?
-
YouKnowbetter almost 11 yearssry.can you tell me how to do that.i am confusing.
-
Hardik Joshi almost 11 years@YouKnowbetter What you get after placing onCreate(null) ?
-
YouKnowbetter almost 11 yearsThen Application crashed.