0

我可以将 QAndroidJniObject::callStaticMethod 用于 java 类中的静态方法。但我不能使用 callMethod ,有没有一个简单的例子。

4

1 回答 1

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;
于 2016-05-26T11:18:07.033 回答