You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/01/02 19:08:39 UTC
[12/14] git commit: CB-5592 Android - Add MIME type to Intent when
opening file:/// URLs
CB-5592 Android - Add MIME type to Intent when opening file:/// URLs
To avoid the "No Activity found to handle Intent..." error.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/176890f3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/176890f3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/176890f3
Branch: refs/heads/master
Commit: 176890f30599fc72d33eeb1f5daa1fa5e6358325
Parents: 2bd006b
Author: gianluca <gi...@trifork.nl>
Authored: Thu Oct 3 14:11:12 2013 +0200
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Dec 20 11:06:10 2013 -0500
----------------------------------------------------------------------
src/android/InAppBrowser.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/176890f3/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index da6b241..aa89446 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -300,7 +300,12 @@ public class InAppBrowser extends CordovaPlugin {
try {
Intent intent = null;
intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(url));
+ Uri uri = Uri.parse(url);
+ if ("file".equals(uri.getScheme())) {
+ intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri));
+ } else {
+ intent.setData(uri);
+ }
this.cordova.getActivity().startActivity(intent);
return "";
} catch (android.content.ActivityNotFoundException e) {