Using the hardware "back" button on Android
This lesson will show you how to handle the user pressing the hardware "back" button on an Android device.
You can download the sample stack from this url: https://tinyurl.com/y6uhx3vx
Android devices have a built in "back" button. LiveCode allows you to support the use of this button within your application by sending a backKey message to the current card.
If you do not pass or handle this message the engine will automatically quit.
Our example stack is simply a stack with 3 cards and 2 buttons that allow you to navigate between them. The "next" button goes to the next card and the "previous" button goes to the previous card.
In this stack we want the hardware "back" button to do the same as the "previous" button, unless we are on the first card, in that case we want the application to quit.
All we need to do is add a backKey message to our stack script that checks what card we are on and takes the appropriate action.
on backKey if the number of this card is 1 then pass backKey else go to the previous card end if end backKey