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.ryblade.openbikebcn.Wearable.PriorityPreset.java

/** Apply the priority to a notification builder */
public void apply(NotificationCompat.Builder builder, NotificationCompat.WearableExtender wearableOptions) {
    builder.setPriority(Notification.PRIORITY_HIGH);
}

From source file:org.linphone.compatibility.ApiTwentyOnePlus.java

public static Notification createMessageNotification(Context context, int msgCount, String msgSender,
        String msg, Bitmap contactIcon, PendingIntent intent) {
    String title;//  w w  w .  ja  va 2  s.  co  m
    if (msgCount == 1) {
        title = msgSender;
    } else {
        title = context.getString(R.string.unread_messages).replace("%i", String.valueOf(msgCount));
    }

    Notification notif = new NotificationCompat.Builder(context).setContentTitle(title).setContentText(msg)
            .setSmallIcon(R.drawable.chat_icon_over).setAutoCancel(true).setContentIntent(intent)
            .setDefaults(Notification.DEFAULT_ALL).setLargeIcon(contactIcon)
            .setCategory(Notification.CATEGORY_MESSAGE).setVisibility(Notification.VISIBILITY_PRIVATE)
            .setPriority(Notification.PRIORITY_HIGH).build();

    return notif;
}

From source file:org.linphone.compatibility.ApiTwentyOnePlus.java

public static Notification createInCallNotification(Context context, String title, String msg, int iconID,
        Bitmap contactIcon, String contactName, PendingIntent intent) {

    Notification notif = new NotificationCompat.Builder(context).setContentTitle(contactName)
            .setContentText(msg).setSmallIcon(iconID).setAutoCancel(false).setContentIntent(intent)
            .setLargeIcon(contactIcon).setCategory(Notification.CATEGORY_CALL)
            .setVisibility(Notification.VISIBILITY_PUBLIC).setPriority(Notification.PRIORITY_HIGH).build();

    return notif;
}

From source file:org.catnut.service.UpgradeService.java

@Override
public void onCreate() {
    super.onCreate();
    mBuilder = new Notification.Builder(this).setSmallIcon(R.drawable.ic_launcher)
            .setPriority(Notification.PRIORITY_HIGH).setAutoCancel(true);
    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}

From source file:eu.operando.proxy.util.NotificationUtil.java

public void displayExfiltratedNotification(String applicationInfo,
        Set<RequestFilterUtil.FilterType> exfiltrated) {
    notificationBuilder = new NotificationCompat.Builder(context).setContentTitle(applicationInfo)
            .setContentText(RequestFilterUtil.messageForMatchedFilters(exfiltrated)).setAutoCancel(true)
            .setOngoing(false).setPriority(Notification.PRIORITY_HIGH)
            .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))
            .setSmallIcon(R.mipmap.ic_launcher); //android.R.color.transparent

    /* Heads-up */
    if (Build.VERSION.SDK_INT >= 22)
        notificationBuilder.setVibrate(new long[0]);

    Notification notification = notificationBuilder.build();
    /* http://javatechig.com/android/android-notification-example-using-notificationcompat */
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Application.NOTIFICATION_SERVICE);
    notificationManager.notify(mainNotificationId, notification);
}

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

/**
 * Helper Method to create and display the notification for advices
 *
 * @param context// ww  w . ja v a 2s .com
 */
public static void remindUserWithCarAdvices(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_remind_user_advices_title))
            .setContentText(showRandomCarAdvices(context))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(showRandomCarAdvices(context)))
            .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_ADVICES_NOTIFICATION_ID, notificationBuilder.build());
}

From source file:com.commonsware.android.biglocal.MainActivity.java

private NotificationCompat.Builder buildNormal() {
    NotificationCompat.Builder b = new NotificationCompat.Builder(this);

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL)
            .setContentTitle(getString(R.string.download_complete)).setContentText(getString(R.string.fun))
            .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS))
            .setSmallIcon(android.R.drawable.stat_sys_download_done)
            .setTicker(getString(R.string.download_complete)).setPriority(Notification.PRIORITY_HIGH)
            .setLocalOnly(true).addAction(android.R.drawable.ic_media_play, getString(R.string.play),
                    buildPendingIntent(Settings.ACTION_SETTINGS));

    return (b);/*from w  w  w  .ja  va 2s  .  c om*/
}

From source file:com.commonsware.android.bignotify.MainActivity.java

private NotificationCompat.Builder buildNormal() {
    NotificationCompat.Builder b = new NotificationCompat.Builder(this);

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis())
            .setContentTitle(getString(R.string.download_complete)).setContentText(getString(R.string.fun))
            .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS))
            .setSmallIcon(android.R.drawable.stat_sys_download_done)
            .setTicker(getString(R.string.download_complete)).setPriority(Notification.PRIORITY_HIGH)
            .addAction(android.R.drawable.ic_media_play, getString(R.string.play),
                    buildPendingIntent(Settings.ACTION_SETTINGS));

    return (b);/*  w  w w . j  a va2  s .c  o  m*/
}

From source file:com.example.android.background.utilities.NotificationUtils.java

public static void remindUserBecauseCharging(Context context) {

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimary))
            .setSmallIcon(R.drawable.ic_drink_notification).setLargeIcon(largeIcon(context))
            .setContentTitle(context.getString(R.string.charging_reminder_notification_title))
            .setContentText(context.getString(R.string.charging_reminder_notification_body))
            .setStyle(new NotificationCompat.BigTextStyle()
                    .bigText(context.getString(R.string.charging_reminder_notification_body)))
            .setDefaults(Notification.DEFAULT_VIBRATE).setContentIntent(contentIntent(context))
            .addAction(drinkWaterAction(context)).addAction(ignoreReminderAction(context)).setAutoCancel(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
    }//  w  w w.  j  av  a 2s.co  m

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

    /* WATER_REMINDER_NOTIFICATION_ID allows you to update or cancel the notification later on */
    notificationManager.notify(WATER_REMINDER_NOTIFICATION_ID, notificationBuilder.build());
}

From source file:com.banana.instagrab.helper.NotificationUtils.java

public static void remindUserBecauseCharging(Context context) {
    // COMPLETED (8) In the remindUser method use NotificationCompat.Builder to create a notification
    // that:/*from  w ww .  j av  a 2  s  .c  o  m*/
    // - has a color of R.colorPrimary - use ContextCompat.getColor to get a compatible color
    // - has ic_drink_notification as the small icon
    // - uses icon returned by the largeIcon helper method as the large icon
    // - sets the title to the charging_reminder_notification_title String resource
    // - sets the text to the charging_reminder_notification_body String resource
    // - sets the style to NotificationCompat.BigTextStyle().bigText(text)
    // - sets the notification defaults to vibrate
    // - uses the content intent returned by the contentIntent helper method for the contentIntent
    // - automatically cancels the notification when the notification is clicked
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            //.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
            //.setSmallIcon(R.drawable.ic_drink_notification)
            //.setLargeIcon(largeIcon(context))
            .setContentTitle("?!").setContentText("?!")
            //.setStyle(new NotificationCompat.MessagingStyle.Message()
            .setDefaults(Notification.DEFAULT_VIBRATE).setContentIntent(contentIntent(context))
            .setAutoCancel(false);

    Log.d("hahaha", "1");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
    }
    Log.d("hahaha", "2");
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Log.d("hahaha", "3");
    notificationManager.notify(WATER_REMINDER_NOTIFICATION_ID, notificationBuilder.build());
    Log.d("hahaha", "4");
}