Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] Qt Android Extras: Android API package&class names?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Qt Android Extras: Android API package&class names?

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    morte
    wrote on 15 Dec 2014, 09:37 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gianluca
      wrote on 16 Dec 2014, 09:43 last edited by
      #2

      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");
      @

      1 Reply Last reply
      0
      • M Offline
        M Offline
        morte
        wrote on 16 Dec 2014, 14:10 last edited by
        #3

        Thank you much, that is: i used name-of-constant instead of its value.

        1 Reply Last reply
        0

        1/3

        15 Dec 2014, 09:37

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved