4

I have create an Activity which has a UrhoSharp surface as;

SDLSurface surface = UrhoSurface.CreateSurface(this, typeof(UrhoLayer), appOptions);

Now back button is not Responding. I tried overriding onBackPressed(), but this function is not called when I press back button. How to make the back button work?

TN.
  • 18,874
  • 30
  • 99
  • 157
Santosh
  • 153
  • 1
  • 13

1 Answers1

2

I resolved this by catching the back button press in DispatchKeyEvent. Not a very satisfactory solution, but it works:

    public override bool DispatchKeyEvent(KeyEvent e)
    {
        if (e.Action == KeyEventActions.Up && e.KeyCode == Keycode.Back)
        {
            OnBackPressed();
            return true;
        }
        if (!UrhoSurface.DispatchKeyEvent(e))
            return false;
        return base.DispatchKeyEvent(e);
    }
larspars
  • 1,640
  • 1
  • 15
  • 30
  • It works!! Thanks. Now i have a new problem. After pressing back when i open the activity again UrhoSurface does not load. A black screen appears in place of UrhoSurface view and nothing happens. How to solve this?? – Santosh Jul 11 '16 at 08:21
  • I haven't experienced that, so I would guess that's not an issue with UrhoSharp, and that the problem lies somewhere else in the app logic. – larspars Jul 11 '16 at 11:00