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. How to put mobile application in Suspended state?
Forum Updated to NodeBB v4.3 + New Features

How to put mobile application in Suspended state?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 587 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.
  • L Offline
    L Offline
    levolex
    wrote on last edited by
    #1

    Hello everyone!
    Recently I faced a problem with my mobile application (on Android). Normally in Android applications user can quit application by pressing Back navigation button when in a root screen. Also application can be suspended by pressing Home navigation button or switching to another application. I'd like Back button to act like Home button (i.e suspend application), but I don't know how. I tried the following:

    1. Window::showMinimized() - it doesn't work in Android
    2. Window::hide() - it doesn't work in Android
    3. <meta-data android:name="android.app.background_running" android:value="true"/> - it doesn't change the behaviour
    4. Qt.application.state - is readonly property

    So the quistion is: How can I programatically trigger Home button or can put my application into suspended mode?

    Thanks in advance.

    J.HilkJ 1 Reply Last reply
    1
    • L levolex

      Hello everyone!
      Recently I faced a problem with my mobile application (on Android). Normally in Android applications user can quit application by pressing Back navigation button when in a root screen. Also application can be suspended by pressing Home navigation button or switching to another application. I'd like Back button to act like Home button (i.e suspend application), but I don't know how. I tried the following:

      1. Window::showMinimized() - it doesn't work in Android
      2. Window::hide() - it doesn't work in Android
      3. <meta-data android:name="android.app.background_running" android:value="true"/> - it doesn't change the behaviour
      4. Qt.application.state - is readonly property

      So the quistion is: How can I programatically trigger Home button or can put my application into suspended mode?

      Thanks in advance.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @levolex

      I don't think this is possible at all. The key event comes from the OS and filters through your application.
      I'm unsure if you can send such an event further along the os, without rooting.

      However it's not going to be something build in Qt, but something you'll have to use native code for


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • L Offline
        L Offline
        levolex
        wrote on last edited by levolex
        #3

        @J-Hilk
        Thank you!
        As I understand your answer, I can intercept events from navigation buttons, and for example prevent it from propogation to OS, but I can't change their default actions. The only action I may trigger without using some native code is application quit.

        Am I right?

        J.HilkJ 1 Reply Last reply
        0
        • L levolex

          @J-Hilk
          Thank you!
          As I understand your answer, I can intercept events from navigation buttons, and for example prevent it from propogation to OS, but I can't change their default actions. The only action I may trigger without using some native code is application quit.

          Am I right?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @levolex
          I'm actually not entirely sure what the underlying process is.

          For the "Back Button" you can catch that inside your application, because it's literally the Qt::Key_Back button and simply invokes QApplication::quit() if you don't catch it.

          From what I understand of android, the Home and Menu button are not designed to be processed by any application. Therefore no way to catch those events, without a rooted device.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0

          • Login

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