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 essayé de mettre cette permission "<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />"


Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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);
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 ?