For example, if i have a button called "Restart", and I want to launch again the onCreate where the app is actually.
Asked
Active
Viewed 228 times
5 Answers
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
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