0

For example, if i have a button called "Restart", and I want to launch again the onCreate where the app is actually.

Roberto
  • 35
  • 6

5 Answers5

4

If you want to restart the activity you're in, try this:

Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
startActivity(intent);
Voicu
  • 15,158
  • 9
  • 54
  • 66
2

If you're on API 11+, you can recreate an Activity by calling the recreate method:

activity.recreate();
kabuko
  • 35,577
  • 9
  • 76
  • 92
0

Finish the Activity and launch it again with an Intent, but I don't really see why you would want to do that.

SimonSays
  • 10,606
  • 5
  • 40
  • 51
0

If you are developing for Honeycomb (API 11) or later you can call recreate()

user2340612
  • 9,145
  • 4
  • 40
  • 63
0

You may want to use the onPaint event with invalidate() if all you want to do is refresh.

user2347763
  • 461
  • 2
  • 10