Android / iOS - Signals if suspended / killed
-
FWIW: Read some Threads about this and then did some tests:
Qt 5.7 - Android 6.0.1, iOS 9.3Here's my summary about SIGNALS sent if APP will be paused:
ANDROID:
Leaving the APP using Android BACK Button:
QGuiApplication::aboutToQuit
NO ApplicationState Changed SIGNALUsing Android Buttons HOME or OVERVIEW to minimize the APP:
Qt::ApplicationState(ApplicationInactive) followed by
Qt::ApplicationState(ApplicationSuspended)iOS:
HOME Button to send APP to back:
Qt::ApplicationState(ApplicationInactive) followed by
Qt::ApplicationState(ApplicationSuspended)DoubleClick on HOME:
Qt::ApplicationState(ApplicationInactive) while visible, then if clicking anywhere else:
Qt::ApplicationState(ApplicationSuspended)CLOSE Suspended APP:
NO ApplicationState Changed SIGNALSolution
Apps can be closed without a SIGNAL, to be safe loosing no data, you should watch:
Qt::ApplicationState(ApplicationSuspended)
AND
QGuiApplication::aboutToQuitto do your cleanup code
-
have to add another situation:
iOS
DoubleClick on HOME:
Qt::ApplicationState(ApplicationInactive)
then close the app (swipe minimized app out of visible area):
Qt::ApplicationState(ApplicationSuspended)
immediately followed by
QGuiApplication::aboutToQuit
So it's not a good idea to cleanup / save data from ApplicationSuspended and aboutToQuit, because on iOS both happened and you would do the job twice.
you should watch the state and check if cleanup is running or already was done
(will provide a sample app soon)