Android - NotificationCompat.Generator-stacking-Benachrichtigungen mit setGroup (- Gruppe) funktioniert nicht

Ich möchte stack-Meldungen mit setGroup (wie hier beschrieben: https://developer.android.com/training/wearables/notifications/stacks.html)
Grundsätzlich, ich verwende 0 als Benachrichtigungs-id (immer die gleichen) und builder.setGroup("test_group_key") aber eine neue Meldung ersetzt immer die Vorherige.
Was könnte das problem sein ?

Code:

public BasicNotifier(Context context) {
    super(context);
    notifManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    mBuilder = new NotificationCompat.Builder(context)
        .setSmallIcon(R.drawable.ic_launcher)
        .setSound(alarmSound)
        .setAutoCancel(true);

    stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(getParentActivityClass());

}

public void showNotification(String title, String text, Intent intent, Class cls) {
    if (text.length() > 190)
        text = text.substring(0, 189) + "...";

    mBuilder.setTicker(text).setContentText(text).setContentTitle(title);

    Intent notificationIntent = intent == null ? new Intent() : new Intent(intent);
    notificationIntent.setClass(getContext(), cls);
    stackBuilder.addNextIntent(notificationIntent);

    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);
    mBuilder.setGroup("test_group_key");

    Notification notif = mBuilder.build();
    notif.flags |= Notification.FLAG_AUTO_CANCEL;

    notifManager.notify(replaceOnNew ? 0 : nextId++, notif); //replaceOnNew
                                                                //is "true"

    Log.i(TAG, "Notification shown: " + nextId + " = " + title);
}

EDIT:

Es scheint gibt es ein problem bei der Verwendung NotificationManagerCompat, werden die Benachrichtigungen nicht angezeigt.

  NotificationManagerCompat notificationManager =
            NotificationManagerCompat.from(getContext());
  notificationManager.notify(id, notif);
InformationsquelleAutor Andrei F | 2014-07-30
Schreibe einen Kommentar