Intents on QT android
-
-
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=307605I 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); }
@