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
Forum Updated to NodeBB v4.3 + New Features

Handling commandline args under Android

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 670 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.
  • S Offline
    S Offline
    SeeLook
    wrote on 29 Nov 2015, 16:01 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
    • S Offline
      S Offline
      SeeLook
      wrote on 1 Dec 2015, 21:06 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

      1/2

      29 Nov 2015, 16:01

      • Login

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