1

Using this code:

QAndroidJniObject activity = QtAndroid::androidActivity();
QAndroidJniObject accountManager = QAndroidJniObject::callStaticObjectMethod("android.accounts.AccountManager","get","(Landroid/content/Context;)android.accounts.AccountManager;",activity.object());
qDebug() << accountManager.isValid();

I am trying to get an instance of the android AccountManager in c++. Unfortantly the output of the line qDebug() << accountManager.isValid(); outputs false.

jpo38
  • 20,821
  • 10
  • 70
  • 151
Nathan
  • 7,099
  • 14
  • 61
  • 125

1 Answers1

2

I think this is because of invalid method signature. You forget L. Also your object name is invalid. Look at some Qt examples. It's always like this

jint max = QAndroidJniObject::callStaticMethod("java/lang/Math", "max", "(II)I", a, b);

So valid string is:

QAndroidJniObject accountManager = QAndroidJniObject::callStaticObjectMethod("android/accounts/AccountManager","get","(Landroid/content/Context;)Landroid/accounts/AccountManager;",activity.object());
Evgeny
  • 3,910
  • 2
  • 20
  • 37
  • Oh, good catch. But unfortunately there seem to be something else wrong, because after correcting I still get the same behavior :-(. – Nathan Jan 11 '16 at 11:01
  • Yes! An additional error: change the "." in the returned class to "/". Than Your answer is complete. – Nathan Jan 11 '16 at 11:24