7

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);
Sush
  • 6,839
  • 1
  • 18
  • 26
YouKnowbetter
  • 81
  • 1
  • 1
  • 2
  • Please try and use correct capitalization, spaces, punctuation etc. in your question. Don't rely on other users to do this for you. There are few grammar trolls on StackOverflow, but this borders on insult. – Maarten Bodewes Aug 06 '13 at 14:28

6 Answers6

18

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.

AllenC
  • 2,754
  • 1
  • 41
  • 74
1

This code may work

Intent intent = getIntent();
finish();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
1

Call this method when you need to refresh your activity.

recreate();

syedjibharat
  • 170
  • 12
1

This is in Kotlin, might work for you:

startActivity(intent)
overridePendingTransition(0,0)
finish()
overridePendingTransition(0,0)
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Ima Coder
  • 11
  • 1
0
Intent intent = new Intent(YourActivity.this, YourActivity.class);
YourActivity.this.startActivity(intent);
finish();
-2

The easiest way is to call onCreate(null); and your activity will be like new. For More info See this.

Community
  • 1
  • 1
Hardik Joshi
  • 9,477
  • 12
  • 61
  • 113