I noticed that the Qt documentation offers two methods for calling android native methods but I can't figure out when to use QAndroidJniObject::callMethod
and when to use QAndroidJniObject::callObjectMethod
. What is the rule?
The main difference is that QAndroidJniObject::callMethod
returns a primitive data type like jint
or jbyte
but QAndroidJniObject::callObjectMethod
returns an object of type QAndroidJniObject
.
Using which one all depends on your needs and the return type of the function you want to call. If your function returns an object type like jobject
, jstring
, jarray
,... then you should definitely use QAndroidJniObject::callObjectMethod
. Otherwise you can use either of the two.