Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [Android] How to handle the Back button

This thread is locked; no one can reply to it. rss feed Print
[Android] How to handle the Back button
kenmasters1976
Member #8,794
July 2007

I've been building some Allegro examples for Android and I noticed the Back button does nothing by default. The Back button is an important part in the Android design guidelines. So, how would you go about handling the Back button in your Allegro application? I'm guessing you'd have to write the Back button handling in your application's MainActivity using Java? Shouldn't default Back navigation be integrated into Allegro's AllegroActivity?.

Thanks.

Polybios
Member #12,293
October 2010

IIRC you will receive a key event with the code "ALLEGRO_KEY_BACK".

kenmasters1976
Member #8,794
July 2007

Huh? The documentation doesn't mention such an event in the Events section, nor in the Android platform specifics.

DanielH
Member #934
January 2001
avatar

It's processed as a keyboard event.

/* Since: 5.1.1 */
/* Android only for now */
ALLEGRO_KEY_BACK

Also, check out ex_android.c

kenmasters1976
Member #8,794
July 2007

Ah, right. Thanks.

[EDIT:] Not worth opening another thread for this. I just noticed that Allegro 5.2.6 uses android.hardware.display.DisplayManager which means Allegro programs won't run on older Android APIs. Not necessarily a bug if Allegro is no longer meant to support older APIs but it might be worth bumping the minSdkVersion in the Android code to 17.

Go to: