Santosh Santosh - 4 years ago 326
Android Question

Back Button not Responding in UrhoSharp

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?

Answer Source

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)
            return true;
        if (!UrhoSurface.DispatchKeyEvent(e))
            return false;
        return base.DispatchKeyEvent(e);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download