diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/calendar/alerts/AlertReceiver.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/com/android/calendar/alerts/AlertReceiver.java b/src/com/android/calendar/alerts/AlertReceiver.java index 8c2d4a78..55c7dcc9 100644 --- a/src/com/android/calendar/alerts/AlertReceiver.java +++ b/src/com/android/calendar/alerts/AlertReceiver.java @@ -23,6 +23,8 @@ import android.content.BroadcastReceiver; import android.content.ContentUris; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.database.Cursor; import android.net.Uri; @@ -271,6 +273,13 @@ public class AlertReceiver extends BroadcastReceiver { return new NotificationWrapper(n, notificationId, eventId, startMillis, endMillis, doPopup); } + public static boolean isResolveIntent(Context context, Intent intent) { + final PackageManager packageManager = context.getPackageManager(); + List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, + PackageManager.MATCH_DEFAULT_ONLY); + return (resolveInfo.size() > 0); + } + private static Notification buildBasicNotification(Notification.Builder notificationBuilder, Context context, String title, String summaryText, long startMillis, long endMillis, long eventId, int notificationId, boolean doPopup, int priority, @@ -783,7 +792,7 @@ public class AlertReceiver extends BroadcastReceiver { /** * Create a pending intent to send ourself a broadcast to start maps, using the first map * link available. - * If no links are found, return null. + * If no links or resolve applications are found, return null. */ private static PendingIntent createMapBroadcastIntent(Context context, URLSpan[] urlSpans, long eventId) { @@ -791,12 +800,17 @@ public class AlertReceiver extends BroadcastReceiver { URLSpan urlSpan = urlSpans[span_i]; String urlString = urlSpan.getURL(); if (urlString.startsWith(GEO_PREFIX)) { - Intent broadcastIntent = new Intent(MAP_ACTION); - broadcastIntent.setClass(context, AlertReceiver.class); - broadcastIntent.putExtra(EXTRA_EVENT_ID, eventId); - return PendingIntent.getBroadcast(context, - Long.valueOf(eventId).hashCode(), broadcastIntent, - PendingIntent.FLAG_CANCEL_CURRENT); + Intent geoIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlString)); + geoIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // If this intent couldn't be handle, needn't create the map action. + if (isResolveIntent(context, geoIntent)) { + Intent broadcastIntent = new Intent(MAP_ACTION); + broadcastIntent.setClass(context, AlertReceiver.class); + broadcastIntent.putExtra(EXTRA_EVENT_ID, eventId); + return PendingIntent.getBroadcast(context, + Long.valueOf(eventId).hashCode(), broadcastIntent, + PendingIntent.FLAG_CANCEL_CURRENT); + } } } |