QT JNI,callMetod和callStaticMetod有什么区别

时间:2016-05-25 21:33:20

标签: qt java-native-interface qandroidjniobject

我可以在java类中使用QAndroidJniObject :: callStaticMethod进行静态metod。但是我不能使用callMethod,这是一个简单的例子。

1 个答案:

答案 0 :(得分:0)

像这样:

// get an android WallpaperManager using callStaticObjectMethod()
QAndroidJniObject   activity = QtAndroid::androidActivity();
QAndroidJniObject   context = activity.callObjectMethod("getApplicationContext", "()Landroid/content/Context;");
QAndroidJniObject   wallpaperManager = QAndroidJniObject::callStaticObjectMethod("android/app/WallpaperManager", "getInstance", "(Landroid/content/Context;)Landroid/app/WallpaperManager;", context.object());

// get width and height
jint    w = wallpaperManager.callMethod<jint>("getDesiredMinimumWidth");
jint    h = wallpaperManager.callMethod<jint>("getDesiredMinimumHeight");
qDebug() << "Width:" << w << "Height:" << h;