How come Game.Exit() doesn't destroy the activity?

What is the reasoning behind this? (I would think the expected behavior be the activity getting destroyed)

On the same note: It’s not terribly intuitive to me that OnExiting never gets called after calling Exit(), especially as they follow each other on desktop?

Wouldn’t it be neater if the current android behavior moved to Game.Hide() or something like that, so that OnExiting could always follow Exit() regardless of platform?

I don’t think I’m the only one confused by this. (not saying that means a lot but…)

Thanks

I’m 100% with you on this one.

Game should be expanded to include Suspeding/Resuming events.

Xna on Windows phone which had a similar life cicle as all the mobile platforms at the time (Start, Suspend, Resumed, Terminated) threw an InvalidOperetionException when you call Exit. MG does something similar on iOS but not quite.

1 Like

Maybe the Exit() override method on AndroidGamePlatform.cs which use Game.Activity.MoveTaskToBack(true) should be replace with Finish();

public override void Exit()
{
      Game.Activity.MoveTaskToBack(true);
}

Replace with :

public override void Exit()
{
   Game.Activity.Finish();
}

Calling Finish() will surely call OnStop and the override OnDestroy() method on AndroidGameActivity.cs which contains the destruction of MG game object.