I am creating a Godot Android game and i have a problem; i can't automatically save data when user focuses out of the application. Whether user presses the back button or home button, i need to run some code to save data. In apps that i create with Android Studio, i can easily override the methods onPause() and onStop(), that works as expected: when app goes to background it still runs the code in these methods. But using Godot's notification system, catching the notifications NOTIFICATION_APP_PAUSED and NOTIFICATION_WM_FOCUS_OUT both don't work.
I have considered of creating an android plugin and override lifecycle methods, but its too limited because i can't call my game functions from there.
So is there a viable solution for automatically saving on exit?