/** Erstellt die Notification. */
  private Builder buildNotification() {
    Builder notification =
        new Notification.Builder(context)
            .setContentTitle(options.getTitle())
            .setContentText(options.getMessage())
            .setNumber(options.getBadge())
            .setTicker(options.getTitle())
            .setSmallIcon(options.getIcon())
            .setSound(options.getSound())
            .setAutoCancel(options.getAutoCancel());

    setClickEvent(notification);

    return notification;
  }
示例#2
0
  /** Creates the notification with all its options passed through JS. */
  public Notification build() {
    Uri sound = options.getSoundUri();
    NotificationCompat.BigTextStyle style;
    NotificationCompat.Builder builder;

    style = new NotificationCompat.BigTextStyle().bigText(options.getText());

    builder =
        new NotificationCompat.Builder(context)
            .setDefaults(0)
            .setContentTitle(options.getTitle())
            .setContentText(options.getText())
            .setNumber(options.getBadgeNumber())
            .setTicker(options.getText())
            .setSmallIcon(options.getSmallIcon())
            .setLargeIcon(options.getIconBitmap())
            .setAutoCancel(true)
            .setOngoing(options.isOngoing())
            .setStyle(style)
            .setLights(options.getLedColor(), 500, 500);

    if (sound != null) {
      builder.setSound(sound);
    }

    applyDeleteReceiver(builder);
    applyContentReceiver(builder);

    return new Notification(context, options, builder, triggerReceiver);
  }
  /** Creates the notification. */
  @SuppressLint("NewApi")
  private Builder buildNotification() {
    Bitmap icon = BitmapFactory.decodeResource(context.getResources(), options.getIcon());
    Uri sound = options.getSound();

    Builder notification =
        new Notification.Builder(context)
            .setContentTitle(options.getTitle())
            .setContentText(options.getMessage())
            .setNumber(options.getBadge())
            .setTicker(options.getMessage())
            .setSmallIcon(options.getSmallIcon())
            .setLargeIcon(icon)
            .setAutoCancel(options.getAutoCancel())
            .setOngoing(options.getOngoing());

    if (sound != null) {
      notification.setSound(sound);
    }

    if (Build.VERSION.SDK_INT > 16) {
      notification.setStyle(new Notification.BigTextStyle().bigText(options.getMessage()));
    }

    setClickEvent(notification);

    return notification;
  }