Bug 1100100 - "Downloaded file can't be opened from "Downloads" page" [r=wjohnston]
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -1163,34 +1163,36 @@ public class GeckoAppShell
if (action.equalsIgnoreCase(Intent.ACTION_SEND)) {
Intent shareIntent = getShareIntent(context, targetURI, mimeType, title);
return Intent.createChooser(shareIntent,
context.getResources().getString(R.string.share_title));
}
final Uri uri = normalizeUriScheme(targetURI.indexOf(':') >= 0 ? Uri.parse(targetURI) : new Uri.Builder().scheme(targetURI).build());
- if (mimeType.length() > 0) {
+ if (!TextUtils.isEmpty(mimeType)) {
Intent intent = getIntentForActionString(action);
intent.setDataAndType(uri, mimeType);
return intent;
}
if (!isUriSafeForScheme(uri)) {
return null;
}
final String scheme = uri.getScheme();
// Compute our most likely intent, then check to see if there are any
// custom handlers that would apply.
// Start with the original URI. If we end up modifying it, we'll
// overwrite it.
+ final String extension = MimeTypeMap.getFileExtensionFromUrl(targetURI);
+ final String mimeType2 = getMimeTypeFromExtension(extension);
final Intent intent = getIntentForActionString(action);
- intent.setData(uri);
+ intent.setDataAndType(uri, mimeType2);
if ("vnd.youtube".equals(scheme) &&
!hasHandlersForIntent(intent) &&
!TextUtils.isEmpty(uri.getSchemeSpecificPart())) {
// Return an intent with a URI that will open the YouTube page in the
// current Fennec instance.
final Class<?> c;