Android Service goes to sleep when phone locked



  • Hi all,

    I have very strange problem. I have created app which uses Android Service. Service is reporting to external application via TCP every minute. Everything works as long as I have USB cable (with debug) attached to the phone. When I disconnect debug cable Android Service goes to sleep after a few seconds.

    Service uses QTimer to report updates to external app every minute, and when service goes to sleep network connection is still active, just QTimer inside Android Service doesn't count. I am not an expert but it looks like main event loop inside Service just stops.

    To illustrate the problem I have prepared small example, I know I should paste it here, but there are to many files, including gradle-wrapper.jar (I was following this example qt-android-create-android-service-using-qt/ so my example is here

    It counts seconds, first count is from QTimer inside Android Service, second is QTime difference between time saved inside Service and current QTime when reporting QTimer timeout, they should be the same but if you lock the phone they aren't after some 20 seconds.

    Can someone confirm that ? Is there something wrong with what I'm doing?

    Best Regards
    Marek



  • Some more detaiils, I'm using Qt 5.7.0 on Linux, phone is Samsung Galaxy S3 with Android 4.2.2


  • Qt Champions 2016

    @Marek please provide your example as github repo



  • Hi

    Github repo here

    Best Regards
    Marek



  • Hi all,

    Can someone offer any help on this. I mean how should I proceed.
    Is this a bug and file the report, or have I done something wrong?

    Best Regards
    Marek


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.