使用此代码:
QAndroidJniObject activity = QtAndroid::androidActivity();
QAndroidJniObject accountManager = QAndroidJniObject::callStaticObjectMethod("android.accounts.AccountManager","get","(Landroid/content/Context;)android.accounts.AccountManager;",activity.object());
qDebug() << accountManager.isValid();
我想在c ++中获取android AccountManager的一个实例。不幸的是,行qDebug() << accountManager.isValid();
的输出输出错误。
答案 0 :(得分:2)
我认为这是因为无效的方法签名。你忘了L
。您的对象名称也无效。看看一些Qt例子。它总是像这样
jint max = QAndroidJniObject :: callStaticMethod(“java / lang / Math”, “max”,“(II)I”,a,b);
如此有效的字符串是:
QAndroidJniObject accountManager = QAndroidJniObject::callStaticObjectMethod("android/accounts/AccountManager","get","(Landroid/content/Context;)Landroid/accounts/AccountManager;",activity.object());