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. Android app based on QMainWindow fails to restart
Forum Update on Tuesday, May 27th 2025

Android app based on QMainWindow fails to restart

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 1 Posters 1.2k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    simon_6162
    wrote on 10 Oct 2015, 21:43 last edited by simon_6162 10 Oct 2015, 22:03
    #1

    I have an application which is a simple form based on a qMainWindow. The application is creating a Bluetooth Smart link, when it opens, and displays some values from the remote sensor, I have a close button (qPushButton) that disconnects the link and then call mainwindow.close() This all works OK and I go back to my android home screen, but the next time I click on the application icon in the launcher, the app doesn't start up properly, it appears to load the java splash screen and nothing else happens, if I kill this with a task manager my app will load correctly the next time around.

    I've scattered log messages throughout the C++ code (I'm actually using PyQt and pyqtdeploy) and Java code. The C++ main.cpp of pyqtdeploy is exiting normally when I call mainwindow.close(), but the Java wrapper code doesn't close, it just gets suspended to the background the last thing to be called appears to be onPanelClosed() . I get no logging at all when I try to restart the application, it just looks like it hangs on activity.xml (the splash screen). I did try adding android.os.Process.killProcess(android.os.Process.myPid()); into onPanelClosed(), this does let me close and open the application again, but onPanelClosed() is also called when I use a menu so its not a good solution. Does anyone have any pointers?

    I should add this all works just fine on Linux. I believe the issue is in the java application lifecycle in android, but I know next to nothing about Android.

    EDIT - I forgot to mention I also tried to overloading changeEvent() and seeing if I could use that to just disconnect my bluetooh and hide, but on android this event doesn't appear to work, but it does on Linux.
    Thanks
    Simon

    S 1 Reply Last reply 15 Oct 2015, 17:33
    0
    • S simon_6162
      10 Oct 2015, 21:43

      I have an application which is a simple form based on a qMainWindow. The application is creating a Bluetooth Smart link, when it opens, and displays some values from the remote sensor, I have a close button (qPushButton) that disconnects the link and then call mainwindow.close() This all works OK and I go back to my android home screen, but the next time I click on the application icon in the launcher, the app doesn't start up properly, it appears to load the java splash screen and nothing else happens, if I kill this with a task manager my app will load correctly the next time around.

      I've scattered log messages throughout the C++ code (I'm actually using PyQt and pyqtdeploy) and Java code. The C++ main.cpp of pyqtdeploy is exiting normally when I call mainwindow.close(), but the Java wrapper code doesn't close, it just gets suspended to the background the last thing to be called appears to be onPanelClosed() . I get no logging at all when I try to restart the application, it just looks like it hangs on activity.xml (the splash screen). I did try adding android.os.Process.killProcess(android.os.Process.myPid()); into onPanelClosed(), this does let me close and open the application again, but onPanelClosed() is also called when I use a menu so its not a good solution. Does anyone have any pointers?

      I should add this all works just fine on Linux. I believe the issue is in the java application lifecycle in android, but I know next to nothing about Android.

      EDIT - I forgot to mention I also tried to overloading changeEvent() and seeing if I could use that to just disconnect my bluetooh and hide, but on android this event doesn't appear to work, but it does on Linux.
      Thanks
      Simon

      S Offline
      S Offline
      simon_6162
      wrote on 15 Oct 2015, 17:33 last edited by simon_6162
      #2

      More info -

      It appears that this is unique to pyqtdeploy code and not a generic QT issue. If I try and of the example applications they stop and start OK. If I try anything with python it does not.

      I can see that the jave code QtNative.finish() is called from the native code after the native code has returned with exit code 0. After this The activity calls finish. At some point later QtApplication.invokeDelegateMethod() makes a call to the QtActivityDelegate.OnPause handler, which calls QtNative.updateApplicationState(2); which never returns......Is this because the native thread is no more?

      As a workaround I've overloaded finish within QtActivity.java

      @Override
      public void finish() {
      super.finish();
      /* force kill the app */
      android.os.Process.killProcess(android.os.Process.myPid());
      }

      Any suggestions on a real fix would be welcome.

      1 Reply Last reply
      0

      1/2

      10 Oct 2015, 21:43

      • Login

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