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. JNI callObject fails: Intent putExtra (ACTION_SEND)
QtWS25 Last Chance

JNI callObject fails: Intent putExtra (ACTION_SEND)

Scheduled Pinned Locked Moved Solved Mobile and Embedded
androidjniqtandroidextrasqtandroid
3 Posts 2 Posters 1.7k Views
  • 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.
  • E Offline
    E Offline
    ekkescorner
    Qt Champions 2016
    wrote on 19 Nov 2017, 15:20 last edited by
    #1

    I'm just developing a sample APP to demonstrate HowTo VIEW or EDIT files from inside your APP in other APPs,
    then getting Response code to see if User canceled or saved the edited file.
    There are some traps - per ex. you cannot directly use files stored as APP DATA - you must copy them first to DOCUMENTS location, then when user has done his work copy this file back into your APP or only delete if user canceled.
    I'll demonstrate how such a workflow could be implemented.
    The Android part is nearly done, iOS work in progress
    APP and Blog will be published in a week or so

    Now I'm having a problem creating an Android Intent via JNI for SEND_FILE action.
    from Java this works:

    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    

    My JNI call:

    jniIntent.callObjectMethod("putExtra", 
    	"(Ljava/lang/String;Landroid/net/Uri;)Landroid/content/Intent;", 
    		jniExtra.object<jstring>(), 
    		jniUri.object<jobject>());
    

    reports an error:
    java.lang.NoSuchMethodError: no non-static method "Landroid/content/Intent;.putExtra(Ljava/lang/String;Landroid/net/Uri;)Landroid/content/Intent;"

    another JNI call for ACTION_VIEW or ACTION_EDIT where I have to set the uri in method setDataAndType it works:

    jniIntent.callObjectMethod("setDataAndType", 
    	"(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;", 
    		jniUri.object<jobject>(), 
    		jniType.object<jstring>());
    

    any idea what's wrong with my JNI Call for putExtra ?

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
    5.15 --> 6.8 https://t1p.de/ekkeChecklist
    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kyrw
      wrote on 23 Aug 2018, 16:30 last edited by
      #2

      You were missing the uri type. IT`s not an String, its a Parceable

      intent.callObjectMethod("putExtra", "(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;", QAndroidJniObject::fromString("android.intent.extra.STREAM").object<jstring>(), uri.object<jobject>());

      E 1 Reply Last reply 28 Aug 2018, 09:13
      1
      • K Kyrw
        23 Aug 2018, 16:30

        You were missing the uri type. IT`s not an String, its a Parceable

        intent.callObjectMethod("putExtra", "(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;", QAndroidJniObject::fromString("android.intent.extra.STREAM").object<jstring>(), uri.object<jobject>());

        E Offline
        E Offline
        ekkescorner
        Qt Champions 2016
        wrote on 28 Aug 2018, 09:13 last edited by
        #3

        @Kyrw thx. already found this out but forgot to mention here and to close the thread.

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
        5.15 --> 6.8 https://t1p.de/ekkeChecklist
        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

        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