Qt World Summit: Submit your Presentation

QNetworkConfigurationManager onlineStateChanged SIGNAL && Android, iOS ApplicationState Suspended

  • Qt Champions 2016

    in some of my apps I'm using a server queue where all requests are queued while the APP is offline. If network state changes to online the oldest request will be executed and so on.

    With Android and iOS - if I understand it right - if APP changed ApplicationState from Active to Suspended I'm getting a small amount of time to cleanup and then nothing will happen until ApplicationState changes back to Active.

    If Device changes onLine state while the APP is suspended - what will happen with onlineStateChanged SIGNAL ?
    Will I get the SIGNAL when APP becomes Active again ?
    Or do I have to ask QNetworkConfigurationManager isOnline() to get the actual value ?

  • Qt Champions 2016

    @ekkescorner from my tests it seems Qt is really smart :)
    APP is online
    suspend app
    switch to airplane mode and a minute later back
    open APP - as soon as get Active, both SIGNALS (off, on) are delivered correct

  • Qt Champions 2016

    @ekkescorner so it seems no signal gets lost. (my experiences on Android - have to test from iOS, too)

    but if getting onlineStateChanged() will cause execution of some complex code,
    probably it would be good only to detect the last change and not always swapping between ON and OFF if user was in area with bad network coverage.

    should I disconnect if APP will be suspended and if becomes Active check the state and re-connect to the SIGNAL ?

    What are you doing ?

  • Lifetime Qt Champion


    Depending on what your application needs to do when coming back online, I'd use a clearable debounce timer to ensure it doesn't start too early if connection quality is bad.

  • Qt Champions 2016

    @SGaist thx - have thought the same.
    would work well if Active and bad coverage or coming back from suspended when multi signals are received

Log in to reply