Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用QtAndroid::androidActivity().callObjectMethod获取int值?_Android_Qt_Java Native Interface_Qtandroidextras - Fatal编程技术网

如何使用QtAndroid::androidActivity().callObjectMethod获取int值?

如何使用QtAndroid::androidActivity().callObjectMethod获取int值?,android,qt,java-native-interface,qtandroidextras,Android,Qt,Java Native Interface,Qtandroidextras,我知道使用下面的方法,我可以从Android主活动获取一个字符串到Qt/C++端 QAndroidJniObject my_string = QtAndroid::androidActivity().callObjectMethod<jstring>("someMethod"); QString my_qsrting = my_string.toString(); 如何使用QtAndroid::androidActivity().callObjectMetho

我知道使用下面的方法,我可以从Android主活动获取一个字符串到Qt/C++端

QAndroidJniObject my_string = QtAndroid::androidActivity().callObjectMethod<jstring>("someMethod");
QString  my_qsrting = my_string.toString();
如何使用
QtAndroid::androidActivity().callObjectMethod
收集
int
jint

经过仔细研究,我找不到我问题的答案

Qt版本:

Qt5.12商业版

对于返回原语的方法,不使用
callObjectMethod
;您为此使用:

jint my_int = QtAndroid::androidActivity().callMethod<jint>("someMethod");
jint my_int=QtAndroid::androidActivity().callMethod(“someMethod”);

完美!这就是我需要的:D
jint my_int = QtAndroid::androidActivity().callMethod<jint>("someMethod");