Is there a way to catch onBackPressed and onAppBackgrouded for Android #3557
-
Hi, Is there a way to cache a android lifecycleEvet like onAppBackgrounded() and onAppForegrounded() or is there a any interface for it? I'm also interested in grabbing the back button event. Is there a way to do it ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For As for |
Beta Was this translation helpful? Give feedback.
For
onBackPressed
there seems to be an open issue about something similar at #2910. It is not currently implemented unfortunately.As for
onAppBackgrouded
, I think you should be able to use the Lifecycle API to achieve something similar. You would then useapp.Lifecycle().SetOnExitedForeground(func())
to set a function to run as the application exits the foreground. The fyne_demo application has some examples of the API: https://github.com/fyne-io/fyne/blob/master/cmd/fyne_demo/main.go#L70-L83. I believe this should do what you are looking for.