QT JNI , What is the difference between the callMetod and callStaticMetod

216 views Asked by At

I can use QAndroidJniObject::callStaticMethod for static metod in java class.But I can't use callMethod , Is there an simple example for this.

1

There are 1 answers

1
Devopia On BEST ANSWER

Somthing like this:

// 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;