diff options
author | Martin Koller <kollix@aon.at> | 2015-08-04 21:29:18 +0200 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2015-10-26 11:35:15 +0000 |
commit | 2f7d3cf559e0bdf8643e213de3a36796f6a88bd3 (patch) | |
tree | 149e44fd7cb1856c2e35655687b7568842480789 /src/android | |
parent | c20f92a0fa11c2cc7bad8f69a1e0a8f8b5893df3 (diff) |
Android: auto-detect MIME type for local files to make openUrl work
[ChangeLog][QtCore][Android]
Fixed the opening of a local file using QDesktopServices::openUrl().
For a local file to be viewed with
QDesktopServices::openUrl(), Android needs to be given
the MIME type otherwise it does not start an Intent to view the file.
Task-number: QTBUG-45585
Change-Id: Ifcfce4bff35011f205cfadbdb2b37a1780dac87d
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt5/android/QtNative.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 040eba5e42..11b6ad8cdc 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -100,13 +100,15 @@ public class QtNative } } - public static boolean openURL(String url) + public static boolean openURL(String url, String mime) { boolean ok = true; try { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); + if (!mime.isEmpty()) + intent.setDataAndType(uri, mime); activity().startActivity(intent); } catch (Exception e) { e.printStackTrace(); |