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 2013/12/20 17:18:00 UTC
android commit: CB-5592 Set MIME type for openExternal when scheme is
file:
Updated Branches:
refs/heads/master 98c8b28bf -> 59c8e8b46
CB-5592 Set MIME type for openExternal when scheme is file:
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/59c8e8b4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/59c8e8b4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/59c8e8b4
Branch: refs/heads/master
Commit: 59c8e8b46eb0cb5e5cb4d99d65022f458d33a560
Parents: 98c8b28
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Dec 20 11:17:24 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Dec 20 11:17:24 2013 -0500
----------------------------------------------------------------------
.../src/org/apache/cordova/CordovaWebView.java | 33 +++++++++-----------
1 file changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/59c8e8b4/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 8b5d387..a6a4ac7 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -630,29 +630,24 @@ public class CordovaWebView extends WebView {
// TODO: What about params?
// Load new URL
this.loadUrl(url);
+ return;
}
// Load in default viewer if not
- else {
- LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list. Loading into browser instead. (URL=" + url + ")");
- try {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(url));
- cordova.getActivity().startActivity(intent);
- } catch (android.content.ActivityNotFoundException e) {
- LOG.e(TAG, "Error loading url " + url, e);
- }
- }
+ LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list. Loading into browser instead. (URL=" + url + ")");
}
-
- // Load in default view intent
- else {
- try {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(url));
- cordova.getActivity().startActivity(intent);
- } catch (android.content.ActivityNotFoundException e) {
- LOG.e(TAG, "Error loading url " + url, e);
+ try {
+ // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
+ // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ Uri uri = Uri.parse(url);
+ if ("file".equals(uri.getScheme())) {
+ intent.setDataAndType(uri, resourceApi.getMimeType(uri));
+ } else {
+ intent.setData(uri);
}
+ cordova.getActivity().startActivity(intent);
+ } catch (android.content.ActivityNotFoundException e) {
+ LOG.e(TAG, "Error loading url " + url, e);
}
}