Impossible d'activer les notifications flottantes
Basouli
-
baba83500 Messages postés 3 Statut Membre -
baba83500 Messages postés 3 Statut Membre -
Bonjour,
J'ai épluché internet entier, anglais compris, pour résoudre mon problème sans succès :
Je n'arrive pas à coder une notification flottante et lockScreen. J'arrive à coder une notification qui apparait dans le fil de notif' seulement. j'ai mit cette permission "<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />"
Voici mon code :
Le canal se créé bien, mais quand je vais voir ses paramètre, rien n'est coché.
Je code en Android Oreo 8.1 avec java 11.
Quelqu'un à une idée lumineuse ?
J'ai épluché internet entier, anglais compris, pour résoudre mon problème sans succès :
Je n'arrive pas à coder une notification flottante et lockScreen. J'arrive à coder une notification qui apparait dans le fil de notif' seulement. j'ai mit cette permission "<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />"
Voici mon code :
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);
Le canal se créé bien, mais quand je vais voir ses paramètre, rien n'est coché.
Je code en Android Oreo 8.1 avec java 11.
Quelqu'un à une idée lumineuse ?
Configuration: Windows/ Firefox 94.0
A voir également:
- Notifications flottante c'est quoi
- Historique des notifications android - Guide
- Comment changer le son des notifications - Guide
- Notifications - Guide
- Je ne reçois plus les notifications snap alors que tout est activé - Forum Snapchat
- Comment bloquer les notifications - Guide
3 réponses
il me semble que pour avoir une notification floottante il faut que tu renseigne une vue dans le notificationBuilder
Hello,
Qu'appelles-tu une "notification flottante" ?
A toute fin utile, le guide du développeur est ici : https://developer.android.com/training/notify-user/build-notification
Qu'appelles-tu une "notification flottante" ?
A toute fin utile, le guide du développeur est ici : https://developer.android.com/training/notify-user/build-notification