Qt World Summit: Submit your Presentation

How do I return bool from Android Java code?

  • I'm new to Android and JNI stuff, I basically need to return a boolean from some android java code,

    Now looking at an example I can get a string to return but not sure how to go about returning a bool

    Currently have test.java:

        import org.qtproject.qt5.android.bindings.QtApplication;
        import org.qtproject.qt5.android.bindings.QtActivity;
        import android.content.res.Configuration;
        public class test extends QtActivity
        public static String printBob(int a)
          return "hello bob";
    public boolean teste(){
        Configuration config = getResources().getConfiguration();
        return config.isScreenRound();

    Now the printBob() works fine from:

    QAndroidJniObject str = QAndroidJniObject::callStaticObjectMethod("test",
        return str.toString();

    But I'm not sure how to call the teste() function to return the bool


  • @koahnig I read that initially, the signature for string is of course


    I get that bit, but whatever i put in the last argument fails, I'm new to this stuff it doesn't really make sense

        QAndroidJniObject str = QAndroidJniObject::callStaticObjectMethod("test",

  • @Allstar12345 You have to use full name, with package.
    For example if your class test is in package com.mycompany.application:

     QAndroidJniObject str = QAndroidJniObject::callStaticObjectMethod("com/mycompany/application/test",

Log in to reply