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. Exchanging data between Android Activity and Qt cpp
Forum Updated to NodeBB v4.3 + New Features

Exchanging data between Android Activity and Qt cpp

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 278 Views 2 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.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on last edited by
    #1

    This is my native cpp function

    void OnNFCState(jstring Value) {
       Environment->GetStringUTFChars(Value, nullptr);
    }
    

    and this is the java side

    private static native void OnNFCState(java.lang.String Value);
    

    The app goes to crash at the line

     Environment->GetStringUTFChars(Value, nullptr);
    

    How can I have a QString from java.lang.String?
    Is jstring corresponding to java.lang.String?

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    KroMignonK 1 Reply Last reply
    0
    • mrdebugM mrdebug

      This is my native cpp function

      void OnNFCState(jstring Value) {
         Environment->GetStringUTFChars(Value, nullptr);
      }
      

      and this is the java side

      private static native void OnNFCState(java.lang.String Value);
      

      The app goes to crash at the line

       Environment->GetStringUTFChars(Value, nullptr);
      

      How can I have a QString from java.lang.String?
      Is jstring corresponding to java.lang.String?

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #2

      @mrdebug said in Exchanging data between Android Activity and Qt cpp:

      void OnNFCState(jstring Value) {
      Environment->GetStringUTFChars(Value, nullptr);
      }

      I know this post is old, but just see it today for the first time. To resolve your issue, simply use QAndroidJniObject::toString(), like this:

      void OnNFCState(jstring Value) {
         qDebug() << "Value is" << QAndroidJniObject(Value).toString();
      }
      

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      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