Example usage for android.app Notification PRIORITY_HIGH

List of usage examples for android.app Notification PRIORITY_HIGH

Introduction

In this page you can find the example usage for android.app Notification PRIORITY_HIGH.

Prototype

int PRIORITY_HIGH

To view the source code for android.app Notification PRIORITY_HIGH.

Click Source Link

Document

Higher #priority , for more important notifications or alerts.

Usage

From source file:com.example.mego.adas.utils.NotificationUtils.java

/**
 * Helper Method to create and display accident notification
 *
 * @param context/*from  w  w w .ja  v  a  2s.  com*/
 */
public static void showAccidentNotification(Context context) {
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimary)).setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(largeIcon(context)).setContentTitle(context.getString(R.string.notification_accident))
            .setContentText(context.getString(R.string.car_accident))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(context.getString(R.string.car_accident)))
            .setDefaults(Notification.DEFAULT_VIBRATE).setDefaults(Notification.DEFAULT_SOUND)
            .setContentIntent(contentIntent(context)).setAutoCancel(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
    }

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

    notificationManager.notify(ADAS_ACCIDENT_NOTIFICATION_ID, notificationBuilder.build());
}

From source file:com.clanofthecloud.cotcpushnotifications.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//  w  w  w . j  av a2 s. c  o m
 */
private void sendNotification(String message) {
    Activity currentAct = UnityPlayer.currentActivity;
    Class activityToOpen = currentAct != null ? currentAct.getClass() : UnityPlayerActivity.class;
    Intent intent = new Intent(this, activityToOpen);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    ApplicationInfo ai = null;
    try {
        ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
        int notificationIcon = ai.metaData.getInt("cotc.GcmNotificationIcon", -1);
        if (notificationIcon == -1) {
            Log.e(TAG,
                    "!!!!!!!!! cotc.GcmNotificationIcon not configured in manifest, push notifications won't work !!!!!!!!!");
            return;
        }
        int notificationLargeIcon = ai.metaData.getInt("cotc.GcmNotificationLargeIcon", -1);
        if (notificationLargeIcon == -1) {
            Log.e(TAG, "There is no large icon for push notifs, will only use default icon");
            return;
        }

        String pushNotifName = ai.metaData.getString("cotc.GcmNotificationTitle");
        if (pushNotifName == null) {
            Log.e(TAG,
                    "!!!!!!!!! cotc.GcmNotificationTitle not configured in manifest, push notifications won't work !!!!!!!!!");
            return;
        }

        if (notifManager == null)
            notifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationCompat.Builder notificationBuilder;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            int importance = NotificationManager.IMPORTANCE_HIGH;
            NotificationChannel channel = new NotificationChannel("CotC Channel", "CotC Channel", importance);
            channel.setDescription("CotC Channel");
            notifManager.createNotificationChannel(channel);
            notificationBuilder = new NotificationCompat.Builder(this, "CotC Channel");
        } else
            notificationBuilder = new NotificationCompat.Builder(this);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        notificationBuilder.setSmallIcon(notificationIcon).setContentTitle(pushNotifName)
                .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri)
                .setContentIntent(pendingIntent).setPriority(Notification.PRIORITY_HIGH);
        if (notificationLargeIcon != -1)
            notificationBuilder.setLargeIcon(
                    BitmapFactory.decodeResource(currentAct.getResources(), notificationLargeIcon));

        notifManager.notify(0 /* ID of notification */, notificationBuilder.build());
    } catch (Exception e) {
        Log.w(TAG, "Failed to handle push notification", e);
    }
}

From source file:org.videolan.vlc.gui.tv.RecommendationsService.java

private boolean doRecommendations() {
    mNotificationManager.cancelAll();//from w  ww  .  j a  v  a 2  s  .  c  o  m
    String last = Uri.decode(PreferenceManager.getDefaultSharedPreferences(mContext)
            .getString(PreferencesActivity.VIDEO_LAST, null));
    int id = 0;
    if (last != null) {
        buildRecommendation(MediaLibrary.getInstance().getMediaItem(last), id, Notification.PRIORITY_HIGH);
    }
    ArrayList<MediaWrapper> videoList = MediaLibrary.getInstance().getVideoItems();
    if (videoList == null || videoList.isEmpty())
        return false;
    Bitmap pic;
    Collections.shuffle(videoList);
    for (MediaWrapper mediaWrapper : videoList) {
        if (TextUtils.equals(mediaWrapper.getLocation(), last))
            continue;
        pic = mMediaDatabase.getPicture(mediaWrapper.getUri());
        if (pic != null && pic.getByteCount() > 4 && mediaWrapper.getTime() == 0) {
            buildRecommendation(mediaWrapper, ++id, Notification.PRIORITY_DEFAULT);
        }
        if (id == NUM_RECOMMANDATIONS)
            break;
    }
    return true;
}

From source file:com.achep.acdisplay.App.java

@Override
public void onCreate() {
    mAccessManager = new AccessManager(this);

    AppHeap.getInstance().init(this);
    Config.getInstance().init(this);
    Blacklist.getInstance().init(this);
    SmileyParser.init(this);

    // Init the main notification listener.
    NotificationPresenter.getInstance()//from w  ww.  j  a va  2s.c o m
            .setOnNotificationPostedListener(Config.getInstance().isEnabled() ? Presenter.getInstance() : null);

    super.onCreate();

    // Check the main switch.
    String divider = getString(R.string.settings_multi_list_divider);
    Config config = Config.getInstance();
    if (config.isEnabled()) {
        StringBuilder sb = new StringBuilder();
        boolean foundAny = false;

        PermissionGroup pg = getAccessManager().getMasterPermissions();
        for (Permission permission : pg.permissions) {
            if (!permission.isActive()) {
                if (foundAny) {
                    sb.append(divider);
                } else
                    foundAny = true;
                sb.append(getString(permission.getTitleResource()));
            }
        }

        if (foundAny) {
            String list = sb.toString();
            list = list.charAt(0) + list.substring(1).toLowerCase();

            ConfigBase.Option option = config.getOption(Config.KEY_ENABLED);
            option.write(config, this, false, null);

            final int id = App.ID_NOTIFY_APP_AUTO_DISABLED;
            PendingIntent pendingIntent = PendingIntent.getActivity(this, id,
                    new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
            Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
            NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle()
                    .bigText(getString(R.string.permissions_auto_disabled)).setSummaryText(list);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                    .setContentTitle(getString(R.string.app_name))
                    .setContentText(getString(R.string.permissions_auto_disabled))
                    .setContentIntent(pendingIntent).setLargeIcon(largeIcon)
                    .setSmallIcon(R.drawable.stat_acdisplay).setAutoCancel(true).setStyle(bts)
                    .setPriority(Notification.PRIORITY_HIGH).setColor(App.ACCENT_COLOR);

            NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            nm.notify(id, builder.build());
        }
    }
    // Check the keyguard (without the notification).
    if (config.isKeyguardEnabled() && !getAccessManager().getKeyguardPermissions().isActive()) {
        ConfigBase.Option option = config.getOption(Config.KEY_KEYGUARD);
        option.write(config, this, false, null);
    }

    // Launch keyguard and (or) active mode on
    // app launch.
    KeyguardService.handleState(this);
    ActiveModeService.handleState(this);
    SensorsDumpService.handleState(this);
}

From source file:com.bullmobi.message.App.java

@Override
public void onCreate() {
    mAccessManager = new AccessManager(this);

    AppHeap.getInstance().init(this);
    Config.getInstance().init(this);
    Blacklist.getInstance().init(this);
    SmileyParser.init(this);

    // Init the main notification listener.
    NotificationPresenter.getInstance()// w w w .j  av  a 2  s  . c o m
            .setOnNotificationPostedListener(Config.getInstance().isEnabled() ? Presenter.getInstance() : null);

    super.onCreate();

    // Check the main switch.
    String divider = getString(R.string.settings_multi_list_divider);
    Config config = Config.getInstance();
    if (config.isEnabled()) {
        StringBuilder sb = new StringBuilder();
        boolean foundAny = false;

        PermissionGroup pg = getAccessManager().getMasterPermissions();
        for (Permission permission : pg.permissions) {
            if (!permission.isActive()) {
                if (foundAny) {
                    sb.append(divider);
                } else
                    foundAny = true;
                sb.append(getString(permission.getTitleResource()));
            }
        }

        if (foundAny) {
            String list = sb.toString();
            list = list.charAt(0) + list.substring(1).toLowerCase();

            ConfigBase.Option option = config.getOption(Config.KEY_ENABLED);
            option.write(config, this, false, null);

            final int id = App.ID_NOTIFY_APP_AUTO_DISABLED;
            PendingIntent pendingIntent = PendingIntent.getActivity(this, id,
                    new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
            Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
            NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle()
                    .bigText(getString(R.string.permissions_auto_disabled)).setSummaryText(list);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                    .setContentTitle(getString(R.string.app_name))
                    .setContentText(getString(R.string.permissions_auto_disabled))
                    .setContentIntent(pendingIntent).setLargeIcon(largeIcon)
                    .setSmallIcon(R.drawable.stat_easynotification).setAutoCancel(true).setStyle(bts)
                    .setPriority(Notification.PRIORITY_HIGH).setColor(App.ACCENT_COLOR);

            NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            nm.notify(id, builder.build());
        }
    }
    // Check the keyguard (without the notification).
    if (config.isKeyguardEnabled() && !getAccessManager().getKeyguardPermissions().isActive()) {
        ConfigBase.Option option = config.getOption(Config.KEY_KEYGUARD);
        option.write(config, this, false, null);
    }

    // Launch keyguard and (or) active mode on
    // app launch.
    KeyguardService.handleState(this);
    ActiveModeService.handleState(this);
    SensorsDumpService.handleState(this);
}

From source file:com.hukum.app_framework.application.gcm.controller.AppGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param intent GCM message received.//from   w w  w .  j av  a 2 s  . c o m
 */
private void sendNotification(Intent intent, String message) {
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(getNotificationIcon()).setContentTitle(getString(R.string.app_name))
            .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri)
            .setPriority(Notification.PRIORITY_HIGH)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).setContentIntent(pendingIntent);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        notificationBuilder.setColor(getResources().getColor(R.color.color_accent));
    }
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());
}

From source file:net.networksaremadeofstring.rhybudd.Notifications.java

public static void SendGCMNotification(ZenossEvent Event, Context context) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);

    Time now = new Time();
    now.setToNow();//from  ww  w  .jav a 2  s  .  com

    //We don't need to overwhelm the user with their notification sound / vibrator
    if ((now.toMillis(true) - PreferenceManager.getDefaultSharedPreferences(context).getLong("lastCheck",
            now.toMillis(true))) < 3000) {
        //Log.e("SendGCMNotification", "Not publishing a notification due to stampede control");
        return;
    }

    Intent notificationIntent = new Intent(context, ViewZenossEventsListActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("forceRefresh", true);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

    Uri soundURI = null;
    try {
        if (settings.getBoolean("notificationSound", true)) {
            if (settings.getString("notificationSoundChoice", "").equals("")) {
                soundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            } else {
                try {
                    soundURI = Uri.parse(settings.getString("notificationSoundChoice", ""));
                } catch (Exception e) {
                    soundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                }
            }
        } else {
            soundURI = null;
        }
    } catch (Exception e) {

    }

    String notifTitle = "New Events Received";
    int notifPriority = Notification.PRIORITY_DEFAULT;
    //int AlertType = NOTIFICATION_GCM_GENERIC;

    try {
        if (Event.getSeverity().equals("5")) {
            notifTitle = context.getString(R.string.CriticalNotificationTitle);
            notifPriority = Notification.PRIORITY_MAX;
            //AlertType = NOTIFICATION_GCM_CRITICAL;
        } else if (Event.getSeverity().equals("4")) {
            notifTitle = context.getString(R.string.ErrorNotificationTitle);
            notifPriority = Notification.PRIORITY_HIGH;
            //AlertType = NOTIFICATION_GCM_ERROR;
        } else if (Event.getSeverity().equals("3")) {
            notifTitle = context.getString(R.string.WarnNotificationTitle);
            notifPriority = Notification.PRIORITY_DEFAULT;
            //AlertType = NOTIFICATION_GCM_WARNING;
        } else if (Event.getSeverity().equals("2")) {
            notifTitle = context.getString(R.string.InfoNotificationTitle);
            notifPriority = Notification.PRIORITY_LOW;
            //AlertType = NOTIFICATION_GCM_INFO;
        } else if (Event.getSeverity().equals("1")) {
            notifTitle = context.getString(R.string.DebugNotificationTitle);
            notifPriority = Notification.PRIORITY_MIN;
            //AlertType = NOTIFICATION_GCM_DEBUG;
        }
    } catch (Exception e) {

    }

    long[] vibrate = { 0, 100, 200, 300 };

    try {
        AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

        //Log.e("audio.getRingerMode()",Integer.toString(audio.getRingerMode()));
        switch (audio.getRingerMode()) {
        case AudioManager.RINGER_MODE_SILENT:
            //Do nothing to fix GitHub issue #13
            //Log.e("AudioManager","Doing nothing because we are silent");
            vibrate = new long[] { 0, 0 };
            break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    Intent broadcastMassAck = new Intent();
    broadcastMassAck.setAction(MassAcknowledgeReceiver.BROADCAST_ACTION);
    PendingIntent pBroadcastMassAck = PendingIntent.getBroadcast(context, 0, broadcastMassAck, 0);

    if (Build.VERSION.SDK_INT >= 16) {
        Notification noti = new Notification.BigTextStyle(new Notification.Builder(context)
                .setContentTitle(notifTitle).setPriority(notifPriority).setAutoCancel(true).setSound(soundURI)
                .setVibrate(vibrate).setContentText(Event.getDevice()).setContentIntent(contentIntent)
                .addAction(R.drawable.ic_action_resolve_all, "Acknowledge all Events", pBroadcastMassAck)
                .setSmallIcon(R.drawable.ic_stat_alert)).bigText(
                        Event.getSummary() + "\r\n" + Event.getComponentText() + "\r\n" + Event.geteventClass())
                        .build();

        if (settings.getBoolean("notificationSoundInsistent", false))
            noti.flags |= Notification.FLAG_INSISTENT;

        noti.tickerText = notifTitle;

        NotificationManager mNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mNM.notify(NOTIFICATION_GCM_GENERIC, noti);
    } else {
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.ic_stat_alert).setContentTitle(notifTitle)
                .setContentText(Event.getDevice() + ": " + Event.getSummary()).setContentIntent(contentIntent)
                .setSound(soundURI).setVibrate(vibrate)
                .addAction(R.drawable.ic_action_resolve_all, "Acknowledge all Events", pBroadcastMassAck)
                .setAutoCancel(true).setPriority(notifPriority);

        NotificationManager mNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mNM.notify(NOTIFICATION_GCM_GENERIC, mBuilder.build());
    }
}

From source file:com.amlcurran.messages.notifications.UnreadNotificationBuilder.java

NotificationCompat.Builder buildSingleUnreadNotification(Conversation conversation, Bitmap photo,
        boolean fromNewMessage, CharSequence ticker) {
    NotificationCompat.Action singleUnreadAction = actionBuilder.buildSingleMarkReadAction(conversation);
    NotificationCompat.Action callAction = actionBuilder.call(conversation.getContact());
    NotificationCompat.Builder builder = notificationBuilder.getDefaultBuilder(fromNewMessage);

    analyseMessage(conversation, builder);
    enableVoiceReply(conversation, builder);

    Contact contact = conversation.getContact();
    return builder.setStyle(buildBigStyle(conversation)).addAction(singleUnreadAction).addAction(callAction)
            .setTicker(ticker).setPriority(Notification.PRIORITY_HIGH)
            .addPerson(NotificationBuilder.getContactUri(contact))
            .setContentTitle(conversation.getContact().getDisplayName()).setLargeIcon(photo)
            .setContentIntent(notificationIntentFactory.createViewConversationIntent(conversation))
            .setContentText(conversation.getSummaryText())
            .setWhen(conversation.getTimeOfLastMessage().toMillis());
}

From source file:com.android.messaging.datamodel.MessageNotificationState.java

@Override
public int getPriority() {
    // Returning PRIORITY_HIGH causes L to put up a HUD notification. Without it, the ticker
    // isn't displayed.
    return Notification.PRIORITY_HIGH;
}

From source file:net.kourlas.voipms_sms.notifications.Notifications.java

/**
 * Shows a notification with the specified details.
 *
 * @param contact   The contact that the notification is from.
 * @param shortText The short form of the message text.
 * @param longText  The long form of the message text.
 *//*from  w ww. ja v  a  2  s.com*/
private void showNotification(String contact, String shortText, String longText) {

    String title = Utils.getContactName(applicationContext, contact);
    if (title == null) {
        title = Utils.getFormattedPhoneNumber(contact);
    }
    NotificationCompat.Builder notification = new NotificationCompat.Builder(applicationContext);
    notification.setContentTitle(title);
    notification.setContentText(shortText);
    notification.setSmallIcon(R.drawable.ic_chat_white_24dp);
    notification.setPriority(Notification.PRIORITY_HIGH);
    String notificationSound = Preferences.getInstance(applicationContext).getNotificationSound();
    if (!notificationSound.equals("")) {
        notification.setSound(Uri.parse(Preferences.getInstance(applicationContext).getNotificationSound()));
    }
    String num = Utils.getFormattedPhoneNumber(contact);
    Log.v("prior", num);

    SharedPreferences sharedPreferences = applicationContext.getSharedPreferences("ledData",
            Context.MODE_PRIVATE);
    String cNm = sharedPreferences.getString(title, "3000");
    SharedPreferences sharedPref = applicationContext.getSharedPreferences("color", Context.MODE_PRIVATE);
    int clr = sharedPref.getInt(title, 0xFF02ffff);
    Log.v("saved rate of ", cNm + " for " + title);
    int ledSpeed = 3000;
    int color = 0xFF02ffff;

    if (cNm.equals("500") || cNm.equals("3000")) {
        ledSpeed = Integer.parseInt(cNm);
        color = clr;
    }

    notification.setLights(color, ledSpeed, ledSpeed);

    if (Preferences.getInstance(applicationContext).getNotificationVibrateEnabled()) {
        notification.setVibrate(new long[] { 0, 250, 250, 250 });
    } else {
        notification.setVibrate(new long[] { 0 });
    }
    notification.setColor(0xFF546e7a);
    notification.setAutoCancel(true);
    notification.setStyle(new NotificationCompat.BigTextStyle().bigText(longText));

    Bitmap largeIconBitmap;
    try {
        largeIconBitmap = MediaStore.Images.Media.getBitmap(applicationContext.getContentResolver(),
                Uri.parse(Utils.getContactPhotoUri(applicationContext, contact)));
        largeIconBitmap = Bitmap.createScaledBitmap(largeIconBitmap, 256, 256, false);
        largeIconBitmap = Utils.applyCircularMask(largeIconBitmap);
        notification.setLargeIcon(largeIconBitmap);
    } catch (Exception ignored) {
        // Do nothing.
    }

    Intent intent = new Intent(applicationContext, ConversationActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra(applicationContext.getString(R.string.conversation_extra_contact), contact);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(applicationContext);
    stackBuilder.addParentStack(ConversationActivity.class);
    stackBuilder.addNextIntent(intent);
    notification.setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT));

    Intent replyIntent = new Intent(applicationContext, ConversationQuickReplyActivity.class);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        replyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    } else {
        //noinspection deprecation
        replyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    }
    replyIntent.putExtra(applicationContext.getString(R.string.conversation_extra_contact), contact);
    PendingIntent replyPendingIntent = PendingIntent.getActivity(applicationContext, 0, replyIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);
    NotificationCompat.Action.Builder replyAction = new NotificationCompat.Action.Builder(
            R.drawable.ic_reply_white_24dp, applicationContext.getString(R.string.notifications_button_reply),
            replyPendingIntent);
    notification.addAction(replyAction.build());

    Intent markAsReadIntent = new Intent(applicationContext, MarkAsReadReceiver.class);
    markAsReadIntent.putExtra(applicationContext.getString(R.string.conversation_extra_contact), contact);
    PendingIntent markAsReadPendingIntent = PendingIntent.getBroadcast(applicationContext, 0, markAsReadIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);
    NotificationCompat.Action.Builder markAsReadAction = new NotificationCompat.Action.Builder(
            R.drawable.ic_drafts_white_24dp,
            applicationContext.getString(R.string.notifications_button_mark_read), markAsReadPendingIntent);
    notification.addAction(markAsReadAction.build());

    int id;
    if (notificationIds.get(contact) != null) {
        id = notificationIds.get(contact);
    } else {
        id = notificationIdCount++;
        notificationIds.put(contact, id);
    }
    NotificationManager notificationManager = (NotificationManager) applicationContext
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(id, notification.build());
}