CB-7265 Fix crash when navigating to custom protocol (introduced in 3.5.1)

Conflicts:
	framework/src/org/apache/cordova/CordovaUriHelper.java

Github: close #111
This commit is contained in:
Martin Bektchiev 2014-08-06 15:24:51 +03:00 committed by Andrew Grieve
parent d6eb723b7f
commit 73219bf2d2

View File

@ -19,8 +19,10 @@
package org.apache.cordova;
import android.annotation.TargetApi;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.webkit.WebView;
class CordovaUriHelper {
@ -44,6 +46,7 @@ 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(WebView view, String url) {
// The WebView should support http and https when going on the Internet
if(url.startsWith("http:") || url.startsWith("https:"))
@ -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);