CB-7265 Fix crash when navigating to custom protocol (introduced in 3.5.1) Github: close #111
Project: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/cdcf5f3f Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/cdcf5f3f Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/cdcf5f3f Branch: refs/heads/master Commit: cdcf5f3f1eab216568415ce2d4340b12c508177d Parents: e8868eb Author: Martin Bektchiev <[email protected]> Authored: Wed Aug 6 15:24:51 2014 +0300 Committer: Archana Naik <[email protected]> Committed: Mon Aug 18 12:32:52 2014 -0700 ---------------------------------------------------------------------- framework/src/org/apache/cordova/CordovaUriHelper.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/cdcf5f3f/framework/src/org/apache/cordova/CordovaUriHelper.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/CordovaUriHelper.java b/framework/src/org/apache/cordova/CordovaUriHelper.java index f1c892c..66818cb 100644 --- a/framework/src/org/apache/cordova/CordovaUriHelper.java +++ b/framework/src/org/apache/cordova/CordovaUriHelper.java @@ -19,9 +19,11 @@ package org.apache.cordova; +import android.annotation.TargetApi; import android.content.Intent; import android.net.Uri; import com.amazon.android.webkit.AmazonWebView; +import android.os.Build; class CordovaUriHelper { @@ -44,8 +46,9 @@ class CordovaUriHelper { * @param url The url to be loaded. * @return true to override, false for default behavior */ + @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) boolean shouldOverrideUrlLoading(AmazonWebView view, String url) { - // The WebView should support http and https when going on the Internet + // The WebView should support http and https when going on the Internet if(url.startsWith("http:") || url.startsWith("https:")) { // We only need to whitelist sites on the Internet! @@ -71,7 +74,9 @@ class CordovaUriHelper { intent.setData(Uri.parse(url)); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setComponent(null); - intent.setSelector(null); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { + intent.setSelector(null); + } this.cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error loading url " + url, e);
