From 6f418df9cc931032ffc32a15b6ff268452fe9f01 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Tue, 23 Aug 2022 16:50:45 +0300 Subject: Android: properly retrieve mime type of uri to for openUrl() Retrieve the mime type of the url regardless of whether QFile::exists() returns true or false, because it is nonetheless required when calling openUrl(). Pick-to: 6.2 6.3 6.4 5.15 Fixes: QTBUG-47979 Change-Id: Ia095b76d5d39addb0b115eb97ac6bbae0c18a21f Reviewed-by: Qt CI Bot Reviewed-by: Samuel Mira Reviewed-by: Konstantin Ritt Reviewed-by: Rami Potinkara Reviewed-by: Ville Voutilainen --- src/plugins/platforms/android/qandroidplatformservices.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/android') diff --git a/src/plugins/platforms/android/qandroidplatformservices.cpp b/src/plugins/platforms/android/qandroidplatformservices.cpp index 8f8f702011..2599fe6db2 100644 --- a/src/plugins/platforms/android/qandroidplatformservices.cpp +++ b/src/plugins/platforms/android/qandroidplatformservices.cpp @@ -47,12 +47,13 @@ bool QAndroidPlatformServices::openUrl(const QUrl &theUrl) // if the file is local, we need to pass the MIME type, otherwise Android // does not start an Intent to view this file const auto fileScheme = "file"_L1; - if ((url.scheme().isEmpty() || url.scheme() == fileScheme) && QFile::exists(url.path())) { - // a real URL including the scheme is needed, else the Intent can not be started + + // a real URL including the scheme is needed, else the Intent can not be started + if (url.scheme().isEmpty()) url.setScheme(fileScheme); - QMimeDatabase mimeDb; - mime = mimeDb.mimeTypeForUrl(url).name(); - } + + if (url.scheme() == fileScheme) + mime = QMimeDatabase().mimeTypeForUrl(url).name(); using namespace QNativeInterface; QJniObject urlString = QJniObject::fromString(url.toString()); -- cgit v1.2.3