Can I listen to the strokes on the physical Android button back?

I could not find it in the documents, is there a module or any other way to capture events using the android button back? If it weren’t a very good and probably fast module to add.

+6
source share
1 answer

No: the back button just returns you one item on the history stack. You do something like changing a hash fragment to track navigation through your application (frameworks like Backbone.js can do this automatically for you).

The reason we took this approach is the lack of a hardware support button on iOS, so we fear that people will rely on it in their application, only for an application that will be fundamentally broken on this platform: in order to ensure consistency of completeness for now.

Update : due to popular demand, we added support for controlling the reverse action of a button on Android: http://docs.trigger.io/en/v1.4/modules/event.html#backpressed-addlistener - check backPressed.preventDefault too.

A function is passed to the event handler that, when called, closes the application, so you can have a code like:

 forge.event.backPressed.addListener(function (close) { if (atHomeScreen) { close(); } } 
+9
source

Source: https://habr.com/ru/post/918317/


All Articles