catch app close on Android and iOS
-
Hi all,
I need to save some data before application closes, on Android I have signal when backbutton is pressed and I can save data. On iOS there is no back button, OS will close my app at some point, can I be sure in code to catch this and save data before closing ?
Best.
Marek -
Hi all,
I need to save some data before application closes, on Android I have signal when backbutton is pressed and I can save data. On iOS there is no back button, OS will close my app at some point, can I be sure in code to catch this and save data before closing ?
Best.
Marek@Marek
use theQCoreApplication::aboutToQuit()
signal or afterapp.exec()
(might be already too late though) in your main().
This might only work when the running app is closed by the user and not when the system forcefully decides to shutdown your application. -
@Marek
use theQCoreApplication::aboutToQuit()
signal or afterapp.exec()
(might be already too late though) in your main().
This might only work when the running app is closed by the user and not when the system forcefully decides to shutdown your application.@raven-worx Thanks. So, will this work on iOS ? I mean OS will close application in ordinary manner or forcefully?
-
@raven-worx Thanks. So, will this work on iOS ? I mean OS will close application in ordinary manner or forcefully?
@Marek
i am not quite sure, since i am not very experienced with iOS. Give it a try by switching the app to background and close it afterwards from the "task manager".
On Android the system might stop your application (when in background) in order to claim back resources. -
@Marek
i am not quite sure, since i am not very experienced with iOS. Give it a try by switching the app to background and close it afterwards from the "task manager".
On Android the system might stop your application (when in background) in order to claim back resources.@raven-worx In short it would be best to save data when app is going in background (this will catch iOS and Android case ) and when backbutton on Android is used, right?
-
@raven-worx In short it would be best to save data when app is going in background (this will catch iOS and Android case ) and when backbutton on Android is used, right?
@Marek said in catch app close on Android and iOS:
In short it would be best to save data when app is going in background (this will catch iOS and Android case )
probably yes, you can try to check the application state (QML)
This is actually the better approach than my first advice! -
@Marek said in catch app close on Android and iOS:
In short it would be best to save data when app is going in background (this will catch iOS and Android case )
probably yes, you can try to check the application state (QML)
This is actually the better approach than my first advice!@raven-worx Thanks, I will do some testing but this seems to solve my problem.
-
@raven-worx Thanks, I will do some testing but this seems to solve my problem.
@Marek
in QML:application.state == Qt.ApplicationSuspended // and the following, depending if the state also changes to 'suspended' on quit or not application.aboutToQuit.connect(saveFunction)