Example usage for android.app Notification DEFAULT_ALL

List of usage examples for android.app Notification DEFAULT_ALL

Introduction

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

Prototype

int DEFAULT_ALL

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

Click Source Link

Document

Use all default values (where applicable).

Usage

From source file:Main.java

public static void notify(Context context, int id, String title, String detail) {
    Notification notification = new NotificationCompat.Builder(context).setContentTitle(title).setTicker(detail)
            .setContentText(detail).setDefaults(Notification.DEFAULT_ALL)
            .setSmallIcon(android.R.drawable.ic_dialog_alert)
            .setLargeIcon(/*from  ww  w  .  j  a va  2  s .com*/
                    BitmapFactory.decodeResource(context.getResources(), android.R.drawable.ic_dialog_alert))
            .build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(id, notification);
}

From source file:Main.java

public static void notifyBig(@NonNull Context context, @NonNull String title, @NonNull String msg,
        @DrawableRes int iconId) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new NotificationCompat.Builder(context).setAutoCancel(true)
            .setContentTitle(title).setDefaults(Notification.DEFAULT_ALL).setContentText(msg)
            .setSmallIcon(iconId).setStyle(new NotificationCompat.BigTextStyle().setBigContentTitle(title)
                    .setSummaryText(msg).bigText(msg))
            .build();//from   w  w w  . j  a v a 2 s. c om
    notificationManager.notify(NOTIFICATION_ID, notification);
}

From source file:Main.java

public static void notifyWithImage(@NonNull Context context, @NonNull String title, @NonNull String msg,
        @DrawableRes int iconId, @NonNull Bitmap bitmap) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new NotificationCompat.Builder(context).setAutoCancel(true)
            .setDefaults(Notification.DEFAULT_ALL).setContentTitle(title).setContentText(msg)
            .setSmallIcon(iconId).setStyle(new NotificationCompat.BigPictureStyle().setBigContentTitle(title)
                    .setSummaryText(msg).bigPicture(bitmap))
            .build();/*w w w . j  a  va  2  s.  com*/
    notificationManager.notify(NOTIFICATION_ID, notification);
}

From source file:Main.java

public static void notifyShort(@NonNull Context context, @NonNull String title, @NonNull String msg,
        @DrawableRes int iconId, int nId, @Nullable PendingIntent pendingIntent) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new NotificationCompat.Builder(context).setAutoCancel(true)
            .setDefaults(Notification.DEFAULT_ALL).setContentTitle(title).setContentText(msg)
            .setSmallIcon(iconId).setContentIntent(pendingIntent).build();
    notificationManager.notify(nId, notification);
}

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 . java2  s  . c  o 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:net.eledge.android.europeana.gui.notification.NewBlogNotification.java

public static void notify(final Context context, List<BlogArticle> articles) {
    if ((articles == null) || articles.isEmpty()) {
        return;/*from  w  w w  . ja  v  a2s.  c  om*/
    }
    // cancel earlier notification
    cancel(context);
    final Resources res = context.getResources();

    String blogUrl = UriHelper.URL_BLOG;
    String title = res.getString(R.string.new_blog_notification_title_multiple, articles.size());

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(R.drawable.ic_stat_new_blog)
            .setContentText(res.getText(R.string.app_name)).setPriority(NotificationCompat.PRIORITY_DEFAULT)
            .setTicker(title).setAutoCancel(true);
    if (articles.size() == 1) {
        BlogArticle item = articles.get(0);
        blogUrl = item.guid;
        title = res.getString(R.string.new_blog_notification_title_single, item.title);

    } else {
        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        for (BlogArticle item : articles) {
            inboxStyle.addLine(item.title);
        }
        builder.setStyle(inboxStyle);
    }

    Intent buttonIntent = new Intent(context, UrlButtonReceiver.class);
    buttonIntent.putExtra(UrlButtonReceiver.PARAM_NOTIFICATIONID, Config.NOTIFICATION_NEWBLOG);
    buttonIntent.putExtra(UrlButtonReceiver.PARAM_URL, blogUrl);
    PendingIntent openUrl = PendingIntent.getBroadcast(context, 0, buttonIntent, 0);

    PendingIntent openApp = PendingIntent.getActivity(context, 0, new Intent(context, HomeActivity.class),
            PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(openApp).addAction(0, res.getString(R.string.action_open_browser), openUrl)
            .addAction(0, res.getString(R.string.action_open_app), openApp).setContentTitle(title);

    notify(context, builder.build());
}

From source file:fi.craplab.plugbuddy.PlugNotification.java

public static void notify(final Context context, final int value) {
    final String title = "C\u0413ApL\u2200b PlugBuddy";
    final String text = "Plug got " + ((value == 1) ? "plugged in. Yay plug!" : "unplugged. Bye bye.");

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title)
            .setContentText(text).setPriority(NotificationCompat.PRIORITY_DEFAULT).setAutoCancel(true);

    final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(NOTIFICATION_TAG, 0, builder.build());
}

From source file:ufms.br.com.ufmsapp.notification.NotificationBuilder.java

public static void buildNotification(int iconResId, String title, String msg) {

    builder.setSmallIcon(iconResId);//from  w ww .  j  av  a2 s  .c  o  m
    builder.setContentTitle(title);
    builder.setContentText(msg);
    builder.setDefaults(Notification.DEFAULT_ALL);

    builder.setAutoCancel(true);

    builder.setProgress(100, increment, false);

    Intent intent = new Intent();

    piOpenNotification = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(piOpenNotification);

    Intent intentMap = new Intent();
    intent.setAction("com.android.training.mynotificationapp.openmap");
    piOpenMap = PendingIntent.getActivity(context, 0, intentMap, PendingIntent.FLAG_UPDATE_CURRENT);

    Intent intentDismiss = new Intent();
    intent.setAction("com.android.training.mynotificationapp.dismiss");
    piDismiss = PendingIntent.getActivity(context, 0, intentDismiss, PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setStyle(new NotificationCompat.BigTextStyle().bigText(msg));

    //builder.addAction(R.drawable.ic_place_grey600_24dp, "Map", piOpenMap);

    //builder.addAction(R.drawable.ic_stat_dismiss, "Dismiss", piDismiss);

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

    manager.notify(NOTIFICATION_ID, builder.build());

}

From source file:inc.bait.jubilee.model.notification.NotificationBar.java

static void notify(final Context context, final String message, PendingIntent pendingIntent) {
    AppPreferences preferences = new AppPreferences(context);
    Preference notification = preferences.getPreference(Pref.NOTIFICATION_BAR, true);
    if (!(boolean) notification.getData()) {
        return;/* w  w w  .  ja v a  2s.co m*/
    }
    final Bitmap picture = BitmapUtil.getBitmap(context, R.drawable.jubilee_icon_ps);
    final String title = "Jubilee 2017";
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setDefaults(Notification.DEFAULT_ALL).setContentTitle(title).setContentText(message)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT).setLargeIcon(picture)
            .setSmallIcon(R.drawable.jubilee_icon_ps).setContentIntent(pendingIntent).setAutoCancel(true);
    notify(context, builder.build());
}

From source file:com.commonsware.android.ordered.NoticeReceiver.java

@Override
public void onReceive(Context ctxt, Intent intent) {
    NotificationManager mgr = (NotificationManager) ctxt.getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder b = new NotificationCompat.Builder(ctxt);
    PendingIntent pi = PendingIntent.getActivity(ctxt, 0, new Intent(ctxt, OrderedActivity.class), 0);

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis())
            .setContentTitle(ctxt.getString(R.string.notify_title))
            .setContentText(ctxt.getString(R.string.notify_text))
            .setSmallIcon(android.R.drawable.stat_notify_chat).setTicker(ctxt.getString(R.string.notify_ticker))
            .setContentIntent(pi);//from  w  ww.  j ava2  s . c  o  m

    mgr.notify(NOTIFY_ME_ID, b.build());
}