La méthode ci-dessous est appelée deux fois avec un paramètre différent name
mais seulement 1 notification apparaît sur mon appareil (le dernier). Je pensais que mettre un paramètre de mode de demande unique à l'intérieur PendingIntent.getActivity()
avec name.hashCode()
fonctionnerait mais cela n'a pas résolu le problème. Alors, comment puis-je modifier cette méthode pour que mon appareil affiche 2 notifications à la suite plutôt que la dernière?Android: Comment puis-je afficher 2 notifications à la suite
private void showNotification(String name, String sub) {
Intent intent = new Intent(activity.getApplicationContext(),
FragmentTabsPager.class);
PendingIntent pIntent = PendingIntent.getActivity(
activity.getApplicationContext(), name.hashCode(), intent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
activity.getApplicationContext());
builder.setContentTitle("Hello world"
).setContentText(name+" from "+sub)
.setSmallIcon(R.drawable.icon).setContentIntent(pIntent)
.getNotification();
NotificationManager notificationManager = (NotificationManager) activity
.getApplicationContext().getSystemService(
Context.NOTIFICATION_SERVICE);
Notification notification = builder.getNotification();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}