Qt 5.7 on Android - app hangs after sleep.




Problem: I open the app. wait for the phone to sleep/lock (or you can click on the power button once). Then unlock the phone and the app hangs (does not respond). Then when I click on home and then resume the app, it works again.

Actually the display hangs while the control works (pretty strange).

How I manages to solve it:

In the main qml file:

    Connections {
        target: Qt.application
        onStateChanged: {
            switch (Qt.application.state) {
            case Qt.ApplicationSuspended:
                console.debug("application suspended")
                break
            case Qt.ApplicationHidden:
                console.debug("Application hidden")
                break
            case Qt.ApplicationActive:
                //update()
                //Qt.application.layoutDirection = Qt.LeftToRight   //.setLayoutDirection(Qt.LeftToRight)
                //raise()
                //show()
                //requestActivate()
                //alert(10)
                hide()
                show()
                console.debug("Application active")
                break
            case Qt.ApplicationInactive:
                console.debug("Application inactive")
                break
            }
        }

    }

Comments

Popular Posts