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

Intents on QT android

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 2.8k 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.
  • R Offline
    R Offline
    RahulRaj
    wrote on 30 Dec 2013, 09:23 last edited by
    #1

    Can we use intents on Qt for android ? I need to open a pdf file from the sd card. Once i select a file using the UI, i need to get a list of applications which can open that file( using intents).

    In short, how can we raise an intent in QT for android ?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tomasl
      wrote on 1 Jan 2014, 19:14 last edited by
      #2

      Hi,

      The correct Qt way of opening a local file is using
      @QDesktopServices::openUrl((QUrl("file:///sdcard/temp/file.pdf")))@

      In Qt4 on Android (Neccessitas), I filed a bug on this some years ago:
      "https://bugs.kde.org/show_bug.cgi?id=307605":https://bugs.kde.org/show_bug.cgi?id=307605

      I don't know for sure the current status on this in Qt5, but please go ahead and file a bugreport if it's not fixed.

      My workaround for this at the moment is using Android intents like this (using JNI - java code):
      @import android.net.Uri;
      import android.provider.MediaStore;
      import android.webkit.MimeTypeMap;

      ...

      public void JIntentActionViewFile(final String data)
      {
          Intent intent = new Intent(Intent.ACTION_VIEW);
          MimeTypeMap mime = MimeTypeMap.getSingleton();
          File file = new File(data);
          String ext=file.getName().substring(file.getName().lastIndexOf(".")+1).toLowerCase();
          String type = mime.getMimeTypeFromExtension(ext);
          intent.setDataAndType(Uri.fromFile(file),type);
          QtActivity.startActivity(intent);
      }
      

      @

      1 Reply Last reply
      0

      1/2

      30 Dec 2013, 09:23

      • 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