Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-48631

QAndroidJniObject::CallVoidMethod for android 5.x

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.5.0
    • Extras: Android
    • None
    • arch linux, qt 5.5, qml, android 5.1.1

      with android 5.x art is used by default which is more stricter for calling native code so now one must call CallVoidMethod instead of CallObjectMethod for void functions

      example code:

      QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
              
      QAndroidJniObject pm = activity.callObjectMethod("getPackageManager", "()Landroid/content/pm/PackageManager;");
              
      QAndroidJniObject param = 
      QAndroidJniObject::fromString("com.android.settings");
              
      QAndroidJniObject intent = pm.callObjectMethod("getLaunchIntentForPackage", "(Ljava/lang/String;)Landroid/content/Intent;",param.object<jstring>());
      activity.callObjectMethod("startActivity","(Landroid/content/Intent;)V", intent.object<jobject>());
      

      on android < 5.x this works properly, on 5.x this returns:

      JNI DETECTED ERROR IN APPLICATION: the return type of CallObjectMethodV does not match void android.app.Activity.startActivity(android.content.Intent)
      

      I don't have direct document, some google results
      https://www.linkedin.com/pulse/20141020095300-6497083-getting-your-apps-ready-for-android-lollipop
      https://code.google.com/p/android-developer-preview/issues/detail?id=1410

      maybe this could be currently solved by using QAndroidJniEnvironment, but I would expect QAndroidJniObject::callVoidMethod in androidextras?

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            esabraha Eskil Abrahamsen Blomfeldt
            pkoretic Petar Koretic
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes