当我从MyActivity中的java方法返回一个字符串时,我可以用
打印它QAndroidJniObject asdf = QtAndroid::androidActivity().callObjectMethod("getPath", "(I)Ljava/lang/String;", 10)
qInfo() << asdf.toString();
但是如果我想返回一个数组怎么办?如何使用C ++操作它以及如何将其打印出来?
public class MyActivity extends QtActivity
{
private String [] imagePaths = new String[100];
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//some code
}
public String [] getPath (int index) {
/*some code*/
return imagePaths;
}
}
答案 0 :(得分:0)
为您的任务更好地使用
jobjectArray asdf = QtAndroid::androidActivity()
.callMethod<jobjectArray>("getPath", "(I)Ljava/lang/String;", 10);
相反
QAndroidJniObject asdf = QtAndroid::androidActivity()
.callObjectMethod("getPath", "(I)Ljava/lang/String;", 10)