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. QApplication was not created in the main() thread. Android + calling java
Forum Updated to NodeBB v4.3 + New Features

QApplication was not created in the main() thread. Android + calling java

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 3.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.
  • J Offline
    J Offline
    joant7
    wrote on 19 Nov 2014, 13:29 last edited by
    #1

    I am getting that warning QApplication was not created in the main() thread.

    The app is C++ calling some java functions, all encapsulated in a class extending org.qtproject.qt5.android.bindings.QtActivity

    I am already creating the QApplication in the main() function so I see no way to fix that.

    Until now all was running fine anyway but with Android 5 the app does not start. The error is not explicitly there but later there's an exception

    bq. java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

    when calling QAndroidJniEnvironment::RegisterNatives. that souns very likely to be related.

    Has anyone experienced something similar? (I've seen similar threads but not one related to android + calling java)

    Thanks!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      benlau
      Qt Champions 2016
      wrote on 20 Nov 2014, 17:03 last edited by
      #2

      I have written an example program that can call Java from C++ and C++ from Java's UI thread. You may take a look:

      https://github.com/benlau/qtandroidexamplecode/tree/master/qtandroidrunner

      1 Reply Last reply
      0

      1/2

      19 Nov 2014, 13:29

      • 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