Example usage for android.app PendingIntent FLAG_UPDATE_CURRENT

List of usage examples for android.app PendingIntent FLAG_UPDATE_CURRENT

Introduction

In this page you can find the example usage for android.app PendingIntent FLAG_UPDATE_CURRENT.

Prototype

int FLAG_UPDATE_CURRENT

To view the source code for android.app PendingIntent FLAG_UPDATE_CURRENT.

Click Source Link

Document

Flag indicating that if the described PendingIntent already exists, then keep it but replace its extra data with what is in this new Intent.

Usage

From source file:at.vcity.androidimsocket.services.IMService.java

/**
 * Show a notification while this service is running.
 * @param msg//w  w w .j a va2  s . co  m
 **/
private void showNotification(MessageInfo msg)//String userId, String msg, String msgtype)
{
    //FriendInfo f=FriendController.getFriendInfo(userId);
    // Set the icon, scrolling text and TIMESTAMP

    // Get User name from friend controller

    String title = "AndroidIM: You got a new Message! ";
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.stat_sample).setContentTitle(title).setAutoCancel(true);
    //.setContentText(text);

    FriendInfo friend = FriendController.getFriendInfo(msg.fromUserId);

    if (msg.type.equals(MessageInfo.MessageType.TEXT))
        mBuilder.setContentText("New message from " + friend.userName + ": " + msg.content);
    else if (msg.type.equals(MessageInfo.MessageType.IMAGE)) {
        mBuilder.setContentText("New image from " + friend.userName);
    } else {
        mBuilder.setContentText("New voice clip from " + friend.userName);
    }
    Intent i;

    String packagename = this.getPackageName();
    if (isForeground(packagename))
        i = new Intent(this, Messaging.class);
    else
        i = new Intent(this, Login.class);

    i.putExtra(MessageInfo.MESSAGE, msg);
    i.putExtra(FriendInfo.FRIEND, friend);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);

    // Set the info for the views that show in the notification panel.
    // msg.length()>15 ? MSG : msg.substring(0, 15);
    mBuilder.setContentIntent(contentIntent);

    //TODO: it can be improved, for instance message coming from same user may be concatenated
    // next version

    // Send the notification.
    // We use a layout id because it is a unique number.  We use it later to cancel.
    mNM.notify((msg.fromUserId).hashCode(), mBuilder.build());
}

From source file:com.irccloud.android.Notifications.java

@SuppressLint("NewApi")
private android.app.Notification buildNotification(String ticker, int bid, long[] eids, String title,
        String text, Spanned big_text, int count, Intent replyIntent, Spanned wear_text, String network,
        String auto_messages[]) {
    SharedPreferences prefs = PreferenceManager
            .getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext());

    NotificationCompat.Builder builder = new NotificationCompat.Builder(
            IRCCloudApplication.getInstance().getApplicationContext())
                    .setContentTitle(title + ((network != null) ? (" (" + network + ")") : ""))
                    .setContentText(Html.fromHtml(text)).setAutoCancel(true).setTicker(ticker)
                    .setWhen(eids[0] / 1000).setSmallIcon(R.drawable.ic_stat_notify)
                    .setColor(IRCCloudApplication.getInstance().getApplicationContext().getResources()
                            .getColor(R.color.dark_blue))
                    .setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
                    .setCategory(NotificationCompat.CATEGORY_MESSAGE)
                    .setPriority(NotificationCompat.PRIORITY_HIGH).setOnlyAlertOnce(false);

    if (ticker != null && (System.currentTimeMillis() - prefs.getLong("lastNotificationTime", 0)) > 10000) {
        if (prefs.getBoolean("notify_vibrate", true))
            builder.setDefaults(android.app.Notification.DEFAULT_VIBRATE);
        String ringtone = prefs.getString("notify_ringtone", "content://settings/system/notification_sound");
        if (ringtone != null && ringtone.length() > 0)
            builder.setSound(Uri.parse(ringtone));
    }/*w w  w . j a  v a2 s. c  om*/

    int led_color = Integer.parseInt(prefs.getString("notify_led_color", "1"));
    if (led_color == 1) {
        if (prefs.getBoolean("notify_vibrate", true))
            builder.setDefaults(
                    android.app.Notification.DEFAULT_LIGHTS | android.app.Notification.DEFAULT_VIBRATE);
        else
            builder.setDefaults(android.app.Notification.DEFAULT_LIGHTS);
    } else if (led_color == 2) {
        builder.setLights(0xFF0000FF, 500, 500);
    }

    SharedPreferences.Editor editor = prefs.edit();
    editor.putLong("lastNotificationTime", System.currentTimeMillis());
    editor.commit();

    Intent i = new Intent();
    i.setComponent(new ComponentName(IRCCloudApplication.getInstance().getApplicationContext().getPackageName(),
            "com.irccloud.android.MainActivity"));
    i.putExtra("bid", bid);
    i.setData(Uri.parse("bid://" + bid));
    Intent dismiss = new Intent(IRCCloudApplication.getInstance().getApplicationContext().getResources()
            .getString(R.string.DISMISS_NOTIFICATION));
    dismiss.setData(Uri.parse("irccloud-dismiss://" + bid));
    dismiss.putExtra("bid", bid);
    dismiss.putExtra("eids", eids);

    PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(
            IRCCloudApplication.getInstance().getApplicationContext(), 0, dismiss,
            PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(
            PendingIntent.getActivity(IRCCloudApplication.getInstance().getApplicationContext(), 0, i,
                    PendingIntent.FLAG_UPDATE_CURRENT));
    builder.setDeleteIntent(dismissPendingIntent);

    if (replyIntent != null) {
        WearableExtender extender = new WearableExtender();
        PendingIntent replyPendingIntent = PendingIntent.getService(
                IRCCloudApplication.getInstance().getApplicationContext(), bid + 1, replyIntent,
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT);
        extender.addAction(
                new NotificationCompat.Action.Builder(R.drawable.ic_reply, "Reply", replyPendingIntent)
                        .addRemoteInput(
                                new RemoteInput.Builder("extra_reply").setLabel("Reply to " + title).build())
                        .build());

        if (count > 1 && wear_text != null)
            extender.addPage(
                    new NotificationCompat.Builder(IRCCloudApplication.getInstance().getApplicationContext())
                            .setContentText(wear_text).extend(new WearableExtender().setStartScrollBottom(true))
                            .build());

        NotificationCompat.CarExtender.UnreadConversation.Builder unreadConvBuilder = new NotificationCompat.CarExtender.UnreadConversation.Builder(
                title + ((network != null) ? (" (" + network + ")") : ""))
                        .setReadPendingIntent(dismissPendingIntent).setReplyAction(replyPendingIntent,
                                new RemoteInput.Builder("extra_reply").setLabel("Reply to " + title).build());

        if (auto_messages != null) {
            for (String m : auto_messages) {
                if (m != null && m.length() > 0) {
                    unreadConvBuilder.addMessage(m);
                }
            }
        } else {
            unreadConvBuilder.addMessage(text);
        }
        unreadConvBuilder.setLatestTimestamp(eids[count - 1] / 1000);

        builder.extend(extender)
                .extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConvBuilder.build()));
    }

    if (replyIntent != null && prefs.getBoolean("notify_quickreply", true)) {
        i = new Intent(IRCCloudApplication.getInstance().getApplicationContext(), QuickReplyActivity.class);
        i.setData(Uri.parse("irccloud-bid://" + bid));
        i.putExtras(replyIntent);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        PendingIntent quickReplyIntent = PendingIntent.getActivity(
                IRCCloudApplication.getInstance().getApplicationContext(), 0, i,
                PendingIntent.FLAG_UPDATE_CURRENT);
        builder.addAction(R.drawable.ic_action_reply, "Quick Reply", quickReplyIntent);
    }

    android.app.Notification notification = builder.build();

    RemoteViews contentView = new RemoteViews(
            IRCCloudApplication.getInstance().getApplicationContext().getPackageName(), R.layout.notification);
    contentView.setTextViewText(R.id.title, title + " (" + network + ")");
    contentView.setTextViewText(R.id.text,
            (count == 1) ? Html.fromHtml(text) : (count + " unread highlights."));
    contentView.setLong(R.id.time, "setTime", eids[0] / 1000);
    notification.contentView = contentView;

    if (Build.VERSION.SDK_INT >= 16 && big_text != null) {
        RemoteViews bigContentView = new RemoteViews(
                IRCCloudApplication.getInstance().getApplicationContext().getPackageName(),
                R.layout.notification_expanded);
        bigContentView.setTextViewText(R.id.title,
                title + (!title.equals(network) ? (" (" + network + ")") : ""));
        bigContentView.setTextViewText(R.id.text, big_text);
        bigContentView.setLong(R.id.time, "setTime", eids[0] / 1000);
        if (count > 3) {
            bigContentView.setViewVisibility(R.id.more, View.VISIBLE);
            bigContentView.setTextViewText(R.id.more, "+" + (count - 3) + " more");
        } else {
            bigContentView.setViewVisibility(R.id.more, View.GONE);
        }
        if (replyIntent != null && prefs.getBoolean("notify_quickreply", true)) {
            bigContentView.setViewVisibility(R.id.actions, View.VISIBLE);
            bigContentView.setViewVisibility(R.id.action_divider, View.VISIBLE);
            i = new Intent(IRCCloudApplication.getInstance().getApplicationContext(), QuickReplyActivity.class);
            i.setData(Uri.parse("irccloud-bid://" + bid));
            i.putExtras(replyIntent);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            PendingIntent quickReplyIntent = PendingIntent.getActivity(
                    IRCCloudApplication.getInstance().getApplicationContext(), 0, i,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            bigContentView.setOnClickPendingIntent(R.id.action_reply, quickReplyIntent);
        }
        notification.bigContentView = bigContentView;
    }

    return notification;
}

From source file:org.metawatch.manager.Monitors.java

static void startAlarmTicker(Context context) {
    if (Preferences.logging)
        Log.d(MetaWatch.TAG, "startAlarmTicker()");
    alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    intent = new Intent(context, AlarmReceiver.class);
    intent.putExtra("action_update", "update");
    sender = PendingIntent.getBroadcast(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, 0, AlarmManager.INTERVAL_HALF_HOUR, sender);
}

From source file:co.shunya.gita.player.MusicService.java

/**
 * Updates the notification.//from ww  w. j a v a  2 s.c  o  m
 */
void updateNotification(String text, int rsdId) {
    PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0,
            new Intent(getApplicationContext(), MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
    Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.gopinathji);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext());
    builder.setAutoCancel(false).setSmallIcon(rsdId).setLargeIcon(icon)
            .setContentTitle(getString(R.string.app_name_reader)).setContentText(text).setOngoing(true);
    builder.setContentIntent(pi);
    issueNotification(builder);
}

From source file:com.chen.mail.utils.NotificationUtils.java

/**
 * Validate the notifications notification.
 *//*from   w  w w.j a v a  2  s  .  c  o m*/
private static void validateNotifications(Context context, final Folder folder, final Account account,
        boolean getAttention, boolean ignoreUnobtrusiveSetting, NotificationKey key) {

    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    final NotificationMap notificationMap = getNotificationMap(context);
    if (LogUtils.isLoggable(LOG_TAG, LogUtils.VERBOSE)) {
        LogUtils.i(LOG_TAG, "Validating Notification: %s mapSize: %d " + "folder: %s getAttention: %b",
                createNotificationString(notificationMap), notificationMap.size(), folder.name, getAttention);
    } else {
        LogUtils.i(LOG_TAG, "Validating Notification, mapSize: %d " + "getAttention: %b",
                notificationMap.size(), getAttention);
    }
    // The number of unread messages for this account and label.
    final Integer unread = notificationMap.getUnread(key);
    final int unreadCount = unread != null ? unread.intValue() : 0;
    final Integer unseen = notificationMap.getUnseen(key);
    int unseenCount = unseen != null ? unseen.intValue() : 0;

    Cursor cursor = null;

    try {
        final Uri.Builder uriBuilder = folder.conversationListUri.buildUpon();
        uriBuilder.appendQueryParameter(UIProvider.SEEN_QUERY_PARAMETER, Boolean.FALSE.toString());
        // Do not allow this quick check to disrupt any active network-enabled conversation
        // cursor.
        uriBuilder.appendQueryParameter(UIProvider.ConversationListQueryParameters.USE_NETWORK,
                Boolean.FALSE.toString());
        cursor = context.getContentResolver().query(uriBuilder.build(), UIProvider.CONVERSATION_PROJECTION,
                null, null, null);
        if (cursor == null) {
            // This folder doesn't exist.
            LogUtils.i(LOG_TAG, "The cursor is null, so the specified folder probably does not exist");
            clearFolderNotification(context, account, folder, false);
            return;
        }
        final int cursorUnseenCount = cursor.getCount();

        // Make sure the unseen count matches the number of items in the cursor.  But, we don't
        // want to overwrite a 0 unseen count that was specified in the intent
        if (unseenCount != 0 && unseenCount != cursorUnseenCount) {
            LogUtils.i(LOG_TAG, "Unseen count doesn't match cursor count.  unseen: %d cursor count: %d",
                    unseenCount, cursorUnseenCount);
            unseenCount = cursorUnseenCount;
        }

        // For the purpose of the notifications, the unseen count should be capped at the num of
        // unread conversations.
        if (unseenCount > unreadCount) {
            unseenCount = unreadCount;
        }

        final int notificationId = getNotificationId(account.getAccountManagerAccount(), folder);

        if (unseenCount == 0) {
            LogUtils.i(LOG_TAG, "validateNotifications - cancelling account %s / folder %s",
                    LogUtils.sanitizeName(LOG_TAG, account.name),
                    LogUtils.sanitizeName(LOG_TAG, folder.persistentId));
            nm.cancel(notificationId);
            return;
        }

        // We now have all we need to create the notification and the pending intent
        PendingIntent clickIntent;

        NotificationCompat.Builder notification = new NotificationCompat.Builder(context);
        notification.setSmallIcon(R.drawable.stat_notify_email);
        notification.setTicker(account.name);

        final long when;

        final long oldWhen = NotificationActionUtils.sNotificationTimestamps.get(notificationId);
        if (oldWhen != 0) {
            when = oldWhen;
        } else {
            when = System.currentTimeMillis();
        }

        notification.setWhen(when);

        // The timestamp is now stored in the notification, so we can remove it from here
        NotificationActionUtils.sNotificationTimestamps.delete(notificationId);

        // Dispatch a CLEAR_NEW_MAIL_NOTIFICATIONS intent if the user taps the "X" next to a
        // notification.  Also this intent gets fired when the user taps on a notification as
        // the AutoCancel flag has been set
        final Intent cancelNotificationIntent = new Intent(
                MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS);
        cancelNotificationIntent.setPackage(context.getPackageName());
        cancelNotificationIntent.setData(Utils.appendVersionQueryParameter(context, folder.folderUri.fullUri));
        cancelNotificationIntent.putExtra(Utils.EXTRA_ACCOUNT, account);
        cancelNotificationIntent.putExtra(Utils.EXTRA_FOLDER, folder);

        notification.setDeleteIntent(
                PendingIntent.getService(context, notificationId, cancelNotificationIntent, 0));

        // Ensure that the notification is cleared when the user selects it
        notification.setAutoCancel(true);

        boolean eventInfoConfigured = false;

        final boolean isInbox = folder.folderUri.equals(account.settings.defaultInbox);
        final FolderPreferences folderPreferences = new FolderPreferences(context, account.getEmailAddress(),
                folder, isInbox);

        if (isInbox) {
            final AccountPreferences accountPreferences = new AccountPreferences(context,
                    account.getEmailAddress());
            moveNotificationSetting(accountPreferences, folderPreferences);
        }

        if (!folderPreferences.areNotificationsEnabled()) {
            LogUtils.i(LOG_TAG, "Notifications are disabled for this folder; not notifying");
            // Don't notify
            return;
        }

        if (unreadCount > 0) {
            // How can I order this properly?
            if (cursor.moveToNext()) {
                final Intent notificationIntent;

                // Launch directly to the conversation, if there is only 1 unseen conversation
                final boolean launchConversationMode = (unseenCount == 1);
                if (launchConversationMode) {
                    notificationIntent = createViewConversationIntent(context, account, folder, cursor);
                } else {
                    notificationIntent = createViewConversationIntent(context, account, folder, null);
                }

                Analytics.getInstance().sendEvent("notification_create",
                        launchConversationMode ? "conversation" : "conversation_list",
                        folder.getTypeDescription(), unseenCount);

                if (notificationIntent == null) {
                    LogUtils.e(LOG_TAG, "Null intent when building notification");
                    return;
                }

                // Amend the click intent with a hint that its source was a notification,
                // but remove the hint before it's used to generate notification action
                // intents. This prevents the following sequence:
                // 1. generate single notification
                // 2. user clicks reply, then completes Compose activity
                // 3. main activity launches, gets FROM_NOTIFICATION hint in intent
                notificationIntent.putExtra(Utils.EXTRA_FROM_NOTIFICATION, true);
                clickIntent = PendingIntent.getActivity(context, -1, notificationIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                notificationIntent.removeExtra(Utils.EXTRA_FROM_NOTIFICATION);

                configureLatestEventInfoFromConversation(context, account, folderPreferences, notification,
                        cursor, clickIntent, notificationIntent, unreadCount, unseenCount, folder, when);
                eventInfoConfigured = true;
            }
        }

        final boolean vibrate = folderPreferences.isNotificationVibrateEnabled();
        final String ringtoneUri = folderPreferences.getNotificationRingtoneUri();
        final boolean notifyOnce = !folderPreferences.isEveryMessageNotificationEnabled();

        if (!ignoreUnobtrusiveSetting && notifyOnce) {
            // If the user has "unobtrusive notifications" enabled, only alert the first time
            // new mail is received in this account.  This is the default behavior.  See
            // bugs 2412348 and 2413490.
            notification.setOnlyAlertOnce(true);
        }

        LogUtils.i(LOG_TAG, "Account: %s vibrate: %s", LogUtils.sanitizeName(LOG_TAG, account.name),
                Boolean.toString(folderPreferences.isNotificationVibrateEnabled()));

        int defaults = 0;

        /*
         * We do not want to notify if this is coming back from an Undo notification, hence the
         * oldWhen check.
         */
        if (getAttention && oldWhen == 0) {
            final AccountPreferences accountPreferences = new AccountPreferences(context, account.name);
            if (accountPreferences.areNotificationsEnabled()) {
                if (vibrate) {
                    defaults |= Notification.DEFAULT_VIBRATE;
                }

                notification.setSound(TextUtils.isEmpty(ringtoneUri) ? null : Uri.parse(ringtoneUri));
                LogUtils.i(LOG_TAG, "New email in %s vibrateWhen: %s, playing notification: %s",
                        LogUtils.sanitizeName(LOG_TAG, account.name), vibrate, ringtoneUri);
            }
        }

        // TODO(skennedy) Why do we do any of the above if we're just going to bail here?
        if (eventInfoConfigured) {
            defaults |= Notification.DEFAULT_LIGHTS;
            notification.setDefaults(defaults);

            if (oldWhen != 0) {
                // We do not want to display the ticker again if we are re-displaying this
                // notification (like from an Undo notification)
                notification.setTicker(null);
            }

            nm.notify(notificationId, notification.build());
        } else {
            LogUtils.i(LOG_TAG, "event info not configured - not notifying");
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}

From source file:com.google.android.apps.muzei.api.MuzeiArtSource.java

private PendingIntent getHandleNextCommandPendingIntent(Context context) {
    return PendingIntent.getService(context, 0, new Intent(ACTION_HANDLE_COMMAND)
            .setComponent(new ComponentName(context, getClass()))
            .setData(Uri.fromParts(URI_SCHEME_COMMAND, Integer.toString(BUILTIN_COMMAND_ID_NEXT_ARTWORK), null))
            .putExtra(EXTRA_COMMAND_ID, BUILTIN_COMMAND_ID_NEXT_ARTWORK).putExtra(EXTRA_SCHEDULED, true),
            PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:com.appsimobile.appsii.Appsi.java

/**
 * Creates a pending intent that can be added to an action in the notification
 *///from  w  w w . j a v  a  2 s . co m
PendingIntent createPendingIntentWithBackstack(Intent resultIntent) {
    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(MainActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

}

From source file:co.shunya.gita.player.MusicService.java

/**
 * Configures service as a foreground service. A foreground service is a service that's doing
 * something the user is actively aware of (such as playing music), and must appear to the
 * user as a notification. That's why we create the notification here.
 *//*w w  w  . j a  v a  2 s  .c o m*/
void setUpAsForeground(String text) {
    PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0,
            new Intent(getApplicationContext(), MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
    Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.gopinathji);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext());
    builder.setAutoCancel(false).setSmallIcon(R.drawable.ic_stat_playing).setLargeIcon(icon)
            .setContentTitle(getString(R.string.app_name_reader)).setContentText(text).setOngoing(true)
            .setContentIntent(pi);
    issueNotification(builder);
    startForeground(NOTIFICATION_ID, mNotification);
}

From source file:net.mceoin.cominghome.NestUtils.java

/**
 * Posts a notification in the notification bar when a transition is detected.
 * If the user clicks the notification, control goes to the main Activity.
 *
 * @param transitionType The type of transition that occurred.
 *///from  www.  j av a 2 s .  com
public static void sendNotification(Context context, String transitionType) {

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean notifications = prefs.getBoolean(MainActivity.PREFS_NOTIFICATIONS, true);

    if (!notifications) {
        if (debug)
            Log.d(TAG, "notifications are turned off");
        return;
    }

    // Create an explicit content Intent that starts the main Activity
    Intent notificationIntent = new Intent(context, MainActivity.class);

    // Construct a task stack
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);

    // Adds the main Activity to the task stack as the parent
    stackBuilder.addParentStack(MainActivity.class);

    // Push the content Intent onto the stack
    stackBuilder.addNextIntent(notificationIntent);

    // Get a PendingIntent containing the entire back stack
    PendingIntent notificationPendingIntent = stackBuilder.getPendingIntent(0,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Get a notification builder that's compatible with platform versions >= 4
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

    // Set the notification contents
    builder.setSmallIcon(R.drawable.home)
            .setContentTitle(context.getString(R.string.nest_transition_notification_title, transitionType))
            .setContentText(context.getString(R.string.nest_transition_notification_text))
            .setContentIntent(notificationPendingIntent);

    // Get an instance of the Notification manager
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    // Issue the notification
    mNotificationManager.notify(0, builder.build());
}