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
  • 16,921
  • 10
  • 60
  • 69
2

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

activity.recreate();
kabuko
  • 36,028
  • 10
  • 80
  • 93
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,867
  • 7
  • 44
  • 59
0

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

user2340612
  • 10,053
  • 4
  • 41
  • 66
0

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

user2347763
  • 469
  • 2
  • 10