Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] Detect when app is sent to backround on Android

[SOLVED] Detect when app is sent to backround on Android

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RudolfVonKrugstein
    wrote on last edited by RudolfVonKrugstein
    #1

    I want to log out the user when the app is sent to the background (working on android).
    Can I somehow detect this on android?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tomaslov
      wrote on last edited by
      #2

      Hi,

      you can simply listen on the Qt.application State property. Here's some qml sample code you can put into main.qml:

      Connections {
          target: Qt.application
          onStateChanged: {
              console.debug("applicationStateChanged: " + Qt.application.state)
                  if (Qt.application.state === Qt.ApplicationActive) {
                      applicationWindow.show()
                      //we're back from idle
                  }
                  else {
                      applicationWindow.hide()
                      //going to background
                  }            
          }
      }
      
      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved