Page 1 of 1
How to program the system back button on an Android device
Posted: Thu Mar 14, 2024 4:15 pm
by yves86
Hi,
I want to include in an Android app, the detection from the system back button on an Android device.
Does any one have an idea ?
Thanks
Re: How to program the system back button on an Android device
Posted: Thu Mar 14, 2024 5:52 pm
by hoerbie
Have a look in the docs on BindCordovaEvent("backbutton", @yourcallback())
Re: How to program the system back button on an Android device
Posted: Fri Mar 15, 2024 12:38 pm
by yves86
Thanks hoerbie,
I have find this topic /
viewtopic.php?p=5398&hilit=BindCordovaEvent#p5398
But its doesnt work !
Re: How to program the system back button on an Android device
Posted: Fri Mar 15, 2024 9:45 pm
by hoerbie
Hi,
I can check my codes next week, when I‘m back in office. But until now I only use this to disable all buttons on Android.
Re: How to program the system back button on an Android device
Posted: Mon Mar 18, 2024 7:07 pm
by hoerbie
Hi,
please try something like the following:
Code: Select all
Procedure BindCordovaEvent(Event.s, *Callback)
!document.addEventListener(v_event, p_callback);
EndProcedure
Procedure back_event()
Debug "CordovaEvent: back"
EndProcedure
Procedure volumeup_event()
Debug "CordovaEvent: volume up"
EndProcedure
Procedure volumedown_event()
Debug "CordovaEvent: volume down"
EndProcedure
Procedure resume_event()
Debug "CordovaEvent: resume"
EndProcedure
Procedure pause_event()
Debug "CordovaEvent: pause"
EndProcedure
;only for Android:
BindCordovaEvent("backbutton", @back_event())
BindCordovaEvent("volumeupbutton", @volumeup_event())
BindCordovaEvent("volumedownbutton", @volumedown_event())
;for Android and iOS
BindCordovaEvent("resume", @resume_event())
BindCordovaEvent("pause", @pause_event())
Can't test it now, but this is copied from my sources, removed my code and changed to demo debug, so it should work this way.
On
https://cordova.apache.org/docs/en/late ... vents.html you can find additional Cordova events.
Re: How to program the system back button on an Android device
Posted: Fri Mar 22, 2024 12:21 pm
by yves86
Hi
Thanks hoerbi,
It's fine.
Re: How to program the system back button on an Android device
Posted: Sat Mar 23, 2024 4:44 am
by Quin
Just tested on my phone (a Pixel 7 pro) and it worked flawlessly. Thanks a ton for this!
hoerbie wrote: Mon Mar 18, 2024 7:07 pm
Hi,
please try something like the following:
Code: Select all
Procedure BindCordovaEvent(Event.s, *Callback)
!document.addEventListener(v_event, p_callback);
EndProcedure
Procedure back_event()
Debug "CordovaEvent: back"
EndProcedure
Procedure volumeup_event()
Debug "CordovaEvent: volume up"
EndProcedure
Procedure volumedown_event()
Debug "CordovaEvent: volume down"
EndProcedure
Procedure resume_event()
Debug "CordovaEvent: resume"
EndProcedure
Procedure pause_event()
Debug "CordovaEvent: pause"
EndProcedure
;only for Android:
BindCordovaEvent("backbutton", @back_event())
BindCordovaEvent("volumeupbutton", @volumeup_event())
BindCordovaEvent("volumedownbutton", @volumedown_event())
;for Android and iOS
BindCordovaEvent("resume", @resume_event())
BindCordovaEvent("pause", @pause_event())
Can't test it now, but this is copied from my sources, removed my code and changed to demo debug, so it should work this way.
On
https://cordova.apache.org/docs/en/late ... vents.html you can find additional Cordova events.