From 2f7d3cf559e0bdf8643e213de3a36796f6a88bd3 Mon Sep 17 00:00:00 2001 From: Martin Koller Date: Tue, 4 Aug 2015 21:29:18 +0200 Subject: 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 --- src/android/jar/src/org/qtproject/qt5/android/QtNative.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/android') 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(); -- cgit v1.2.3