1

使用此代码:

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();输出输出为假。

4

1 回答 1

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());
于 2016-01-11T09:11:46.607 回答