UrhoSamples2019
UrhoSamples2019 copied to clipboard
Android BackButton Press Crashes UrhoSharp SamplyGame [Fixed]
I had modelled my game on SamplyGame, so was also getting hanging when pressing the Android Back Button. To fix, in MainActivity:
public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
{
if (keyCode == Keycode.Back)
{
this.MoveTaskToBack(false);//causes app to go to back, and works when refocussed.
return false; //this prevents OnBackPressed(), call.
}
return base.OnKeyDown(keyCode, e);
}
Then, delete the Esc key condition in SamplyGame, as shown:
SamplyGame.Start() { Input.SubscribeToKeyDown(e => { if (e.Key == Key.Esc) Exit();//<- this causes app crash/hang } }
The app is now sent to the background, and opens nicely when refocussed.