Qt World Summit: Register Today!

Intents on QT android

  • 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 ?

  • Hi,

    The correct Qt way of opening a local file is using

    In Qt4 on Android (Neccessitas), I filed a bug on this some years ago:

    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);


Log in to reply