summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoryingying <yingying@codeaurora.org>2014-01-15 16:59:54 +0800
committerSteve Kondik <steve@cyngn.com>2015-10-18 13:52:39 -0700
commit6433add1b2827a71e2e88fd66e46fecc6bf35223 (patch)
treecd0b5e0e07621bc896f9ba16e74aaa90f58e1ca8 /src
parente4c0ee3ff20b9d98998c7888a2be3912626b0be6 (diff)
downloadandroid_packages_apps_Calendar-6433add1b2827a71e2e88fd66e46fecc6bf35223.tar.gz
android_packages_apps_Calendar-6433add1b2827a71e2e88fd66e46fecc6bf35223.tar.bz2
android_packages_apps_Calendar-6433add1b2827a71e2e88fd66e46fecc6bf35223.zip
Calendar: Do not show "Map" action if there isn't resolve app.
Sometimes the phone didn't contains the map application, and there isn't application to resolve the view map action. So the Calendar needn't to show the "Map" action on the statusbar under this case. CRs-fixed: 619204 Change-Id: I475a3285b23cfbac3a078fb6e89ca6c46575e9bf
Diffstat (limited to 'src')
-rw-r--r--src/com/android/calendar/alerts/AlertReceiver.java28
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);
+ }
}
}