1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
NotificationManager notificationManager = activity.getSystemService(NotificationManager.class);
NotificationChannel channel = new NotificationChannel("timeAlert", "timeAlert", NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("visible in all way possible");
channel.setImportance(NotificationManager.IMPORTANCE_HIGH);
channel.setShowBadge(true);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
channel.setBypassDnd(true);
if (!notificationManager.getNotificationChannels().contains(channel)) {
notificationManager.createNotificationChannel(channel);
}
Notification notification = new NotificationCompat.Builder(activity, "timeAlert")
.setSmallIcon(R.drawable.logonotification)
.setContentTitle("monTitre")
.setContentText("monMessage")
.setColor(activity.getResources().getColor(R.color.primary))
.setColorized(true)
.setPriority(NotificationManager.IMPORTANCE_MAX)
.setDefaults(Notification.DEFAULT_ALL)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentIntent(PendingIntent.getActivity(activity, 0, activity.getIntent(), 0))
.setAutoCancel(true)
.build();
notificationManager.notify(1, notification); |
Partager