J'ai besoin d'un programme qui ajoutera une notification sur Android. Et quand quelqu'un clique sur la notification, cela devrait le conduire à ma deuxième activité.
J'ai établi le code. La notification devrait fonctionner, mais pour une raison quelconque, elle ne fonctionne pas. Le Notificationne montre pas du tout. Je ne sais pas ce qui me manque.
Code de ces fichiers:
Notification n = new Notification.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject")
.setContentIntent(pIntent).setAutoCancel(true)
.setStyle(new Notification.BigTextStyle().bigText(longText))
.build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Hide the notification after it's selected
notificationManager.notify(0, n);
Activitypas lancé? N'est-ceNotificationpas visible?