Android phone back pressed event in thunkable




Hello thunkers, today i want to briefly share with you how to take advantage of the back pressed (when screen1. back pressed) Event.
Most of the time when a user is interacting with your App, they are likely to click on the back button of their android device and when they do, the app is likely to close which they might not have intended to do so. in this case, they would have to launch your app all over again if you are lucky else app stays closed accidentally

There are two(2) ways to take advantage of this event:
Method one
this method involves using a notifier to prompt your app users they are about to exit/close your app when they press their device back button(first time) and allowing the app to close when the user presses the back button again(second time within 5 sec). in this case after the first notification they are made aware that a second press on the back button will actually close the app. This will prevent users who did not intend to close your app not to press on the back button again and encourage users who intend to close the app to press on the back button again in other to exit your app.

See example image below on how to do this in Thunkable

NB: for best results set your timer to 5000(5 seconds)

Method 2
The second method is similar to the first one only that this time round instead of giving your users a notification to press the device back button again to close your app, you rather initiate the notification dialog to give them two options to choose one.

1. Rate App option
2. Close App option
3. cancel option

if the first option is chosen by your app user, you want your app to open to your play store location where your user will rate your app. in this case you will need to use an Activity starter in your app and set its data URI to the URL of your app in the play store etc, then call your ActivityStarter to Start if Rate App option is chosen.

if the second option is chosen, we want the App to close and the third option to cancel and close the prompt dialog notification on the App’s screen.

See example image below on how to do this in Thunkable

A detailed or live demonstration of this topic can be seen in the Sketch Book App uploaded to the Google Play Store

The Sample .aia source code below is a demonstration of how one can take advantage of the Screen Backpressed Event.
BackpresseventSample.aia (887.9 KB)

Thank you and happy Thunking. Goodluck.:sunglasses:

Single Backpress go back to previous page double back press to exit with pop up
Close Application via double tapping Back keys
Is There Any Limitation to the Amount of Files We Can Upload to Thunkable?
Question on the back of the first screen
Need help during app development

thanks @Brainwork i need this.

Press the back button to go to previous location (Web View)

Where do I add 5000?


On the designer, click the Clock component, then on the properties, set the Timer Interval to 5000.


Sir I can’t Find the Extensions Used in this Project to Download and Use in Other Project. Can you please Give me the Link of these two Extensions


yes, because that solution does not use any extension…
you might want to read the first post in this thread about how to do it

split this topic #7

A post was split to a new topic: Close Interstitial ads


after single press back button not going back page direct showing me exit page,can you help


Sir,Backpreesed is not working plz.plz.plz.give me help.
I am waiting your reply
help me sir


Did you try this example project file-


Hallo sir i creat web view when i click back press i got white blank … pleas help



sir, when i used this block (close application) than see this message “Closing Forms is not currently supported during development”


Hi @app_development welcome to the Thunkable community. This message only appears during live testing.

Please install your app on your phone to resolve this issue.