How to exit the game in android?

I tested the game on android phone, and the game doesn’t exit when I press back button. How do I implement this functionality for android?

I may be wrong about this, but I think that some Android devices handle those buttons differently.

Try this:

open game.project
Go down to Android
For input_method, change it to "HiddenInputField"
Rebuild your project and see if it works right now. It might not, but try.

By the way, what’s the model of your test device?

i’m using a Samsung phone with Android kitkat 4.4.2

Exact model number? What I’m wanting to know is what kind of buttons it uses software or hardware for the back button.

Samsung Galaxy S Duos 2 S7582
i do most of my testing on this mobile only since it the only one i have :sweat_smile:

Did you already try testing for KEY_BACK for key_trigger input?

Combine with this http://defold.com/ref/sys/#exit:code

2 Likes

LIke @Pkeod said, you need to listen for KEY_BACK and then trigger sys.exit().

5 Likes

no, i haven’t i’ll try that one.

and how would KEY_BACK work for mobile isn’t it for keyboard input?

The physical or virtual back key on an Android device will generate a KEY_BACK.

oh thanks!!!