我可以在java类中使用QAndroidJniObject :: callStaticMethod进行静态metod。但是我不能使用callMethod,这是一个简单的例子。
答案 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;