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. How to call JAVA method that returns a String?
Forum Updated to NodeBB v4.3 + New Features

How to call JAVA method that returns a String?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 1.4k 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.
  • L Offline
    L Offline
    lqsa
    wrote on 4 Jul 2016, 21:47 last edited by
    #1

    I would like to call a JAVA method that is in my QtActivity that return a string.

    I've tried these, but all gives me a compilation error:

    jstring value = QtAndroid::androidActivity().callMethod<jstring>("getUser", "()Ljava/lang/String;");
    
    jstring value = QtAndroid::androidActivity().callMethod<jstring>("getUser");
    
    error: undefined reference to '_jstring* QAndroidJniObject::callMethod<_jstring*>(char const*, char const*, ...) const'
    
    1 Reply Last reply
    0
    • L Offline
      L Offline
      lqsa
      wrote on 5 Jul 2016, 02:02 last edited by
      #2

      I found it!

          QAndroidJniObject juser = QtAndroid::androidActivity().callObjectMethod("getUser", "()Ljava/lang/String;");
          QString user = juser.toString();
      
      1 Reply Last reply
      2
      • N Offline
        N Offline
        NhlalukoG
        wrote on 11 Nov 2019, 21:45 last edited by
        #3

        Thanks for the tip. The problem was callMethod vs callObjectMethod. I think callObjectMethod is for functions that return L types (classes) and the former for primitive types.

        Thanks

        1 Reply Last reply
        0

        • Login

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