diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java @@ -473,26 +473,28 @@ public void onSuccess(ShareInfo info) { Log.i("SharePlugin", "onSuccess() - Transfer finished for file: " + info.fileDocument.getUri().getPath()); + String mimeType = FilesHelper.getMimeTypeFromFile(info.fileDocument.getName()); + if (info.shouldOpen) { shareNotification.cancel(); Intent intent = new Intent(Intent.ACTION_VIEW); if (Build.VERSION.SDK_INT >= 24) { //Nougat and later require "content://" uris instead of "file://" uris File file = new File(info.fileDocument.getUri().getPath()); Uri contentUri = FileProvider.getUriForFile(device.getContext(), "org.kde.kdeconnect_tp.fileprovider", file); - intent.setDataAndType(contentUri, info.fileDocument.getType()); + intent.setDataAndType(contentUri, mimeType); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { - intent.setDataAndType(info.fileDocument.getUri(), info.fileDocument.getType()); + intent.setDataAndType(info.fileDocument.getUri(), mimeType); } context.startActivity(intent); } else { if (!ShareSettingsActivity.isCustomDestinationEnabled(context)) { Log.i("SharePlugin", "Adding to downloads"); DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); - manager.addCompletedDownload(info.fileDocument.getUri().getLastPathSegment(), device.getName(), true, info.fileDocument.getType(), info.fileDocument.getUri().getPath(), info.fileSize, false); + manager.addCompletedDownload(info.fileDocument.getUri().getLastPathSegment(), device.getName(), true, mimeType, info.fileDocument.getUri().getPath(), info.fileSize, false); } else { //Make sure it is added to the Android Gallery anyway MediaStoreHelper.indexFile(context, info.fileDocument.getUri());