[SOLVED] Qt Android Extras: Android API package&class names?
-
Im trying to open Android Settings from via JNI (using Qt Android Extras),
here is code im using:
@QAndroidJniObject intent("android/content/Intent", "()V");intent.callObjectMethod("setClassName",
"(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;",
//packageName :
QAndroidJniObject::fromString("android.provider.Settings").object<jstring>(),
//className:
QAndroidJniObject::fromString("Settings.ACTION_LOCATION_SOURCE_SETTINGS").object<jstring>());QtAndroid::androidActivity().callObjectMethod("startActivity", "(Landroid/content/Intent;)V", intent.object<jobject>());
@There is error at package and class name strings,
can someone provide an info how i should name Android API packages and classes when working with JNI? -
I see an error ... I don't know if it the only one.
However, the following statement:
@
//packageName :
QAndroidJniObject::fromString("android.provider.Settings").object<jstring>(),
//className:
QAndroidJniObject::fromString("Settings.ACTION_LOCATION_SOURCE_SETTINGS").object<jstring>
@
It's translated into Java passing the string that you specified, so it will be in Java:
@
intent.setClassName( "android.provider.Settings", "Settings.ACTION_LOCATION_SOURCE_SETTINGS" );
@
The first string is ok, because is what setClassName except, but the second is wrong, because you should pass the String attribute of Settings called ACTION_LOCATION_SOURCE_SETTINGS that in java correspond to write:
@
intent.setClassName( "android.provider.Settings", Settings.ACTION_LOCATION_SOURCE_SETTINGS );
@
You see the difference ?!?! (There is no quotes around Settings.ACTION_LOCATION_SOURCE_SETTINGS)To achieve that in Jni with AndroidExtras you need to get the attribute ACTION_LOCATION_SOURCE_SETTINGS from the Settings class:
@
QAndroidJniObject actionLocationSourceSettings = QAndroidJniObject::getStaticField<jstring>("android.provider.Settings", "ACTION_LOCATIO_SOURCE_SETTINGS");
@