Search code examples
androidandroid-activityactivity-finish

Finishing activity doesn't reset it


I'm building a game with a restart button and a home button. When I press the home button it finishes the game activity and opens the home activity. However, when I open the game activity again, the activity looks just like when I finished. What I have read is that finish() will destroy the activity and it's progress and open a new instance when I open it again. What can I do about it? Thanks! (Here's the code to finish the activity and start the home activity)

(ActivityManager is my own class to start an activity)

((Activity) context).finish();
ActivityManager.StartActivity(context, ActivityManager.AvailibleActivities.MainActivity);

Solution

  • I noticed that it was just some variables that didn't reset and after making a reset() function that resets those variables it worked!