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. Handling commandline args under Android

Handling commandline args under Android

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 758 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.
  • SeeLookS Offline
    SeeLookS Offline
    SeeLook
    wrote on last edited by
    #1

    Hi!

    I was able to launch my Qt-Android app by associating file mimetype with it (using <intent-filters> in Manifest.xml) and tapping that file icon in device file browser.
    But the app can't see an argument (file path).
    Is it supported?

    1 Reply Last reply
    0
    • SeeLookS Offline
      SeeLookS Offline
      SeeLook
      wrote on last edited by
      #2

      Seems it is not supported directly by Qt but I found the solution using JNI

      QString getRunArgument() {
        QString argument;
        QAndroidJniObject activity = QtAndroid::androidActivity();
        if (activity.isValid()) {
          QAndroidJniObject intent = activity.callObjectMethod("getIntent", "()Landroid/content/Intent;");
          if (intent.isValid()) {
             QAndroidJniObject data = intent.callObjectMethod("getData", "()Landroid/net/Uri;");
             if (data.isValid()) {
               QAndroidJniObject arg = data.callObjectMethod("getPath", "()Ljava/lang/String;");
               if (arg.isValid())
                 argument = arg.toString();
             }
          }
        }
        return argument;
      }
      

      It works for me

      1 Reply Last reply
      1

      • Login

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