Bonjour à toutes et à tous,
J'ai suivit la documentation officiel d'Android sur le site officiel pour créer une notification (source : https://developer.android.com/guide/...leNotification)

J'ai donc fait un test de mon application et aucun soucis mais dès que je veux le faire sur un Android 8 le drame... Celà m'affiche ceci :
Nom : Erreur.PNG
Affichages : 107
Taille : 20,7 Ko

Je ne comprends pas du tout j'ai suivit le guide officiel à la lettre... 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
protected void sendNotification(String itemName) {
 
        // The id of the channel.
        String CHANNEL_ID = "plop";
        NotificationCompat.Builder mBuilder =
        new NotificationCompat.Builder(this, CHANNEL_ID)
            .setSmallIcon(R.drawable.ic_menu_share)
            .setContentTitle("Objet trouvé")
            .setContentText("" + itemName);
 
        // Creates an explicit intent for an Activity in your app
        Intent resultIntent = new Intent(this, TrainingActivity.class);
 
        // The stack builder object will contain an artificial back stack for the
        // started Activity.
        // This ensures that navigating backward from the Activity leads out of
        // your app to the Home screen.
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        // Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addParentStack(TrainingActivity.class);
        // Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
 
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 
        // mNotificationId is a unique integer your app uses to identify the
        // notification. For example, to cancel the notification, you can pass its ID
        // number to NotificationManager.cancel().
        mNotificationManager.notify(101, mBuilder.build());
    }
Merci beaucoup de votre aide car je suis perdu

P.S: j'ai même essayé ceci sans succès :

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
50
51
52
53
54
55
56
57
    protected void sendNotification(String itemName) {
 
        String CHANNEL_ID = "1000";
 
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 
            NotificationChannel mChannel = new NotificationChannel("1000", "plop", NotificationManager.IMPORTANCE_HIGH);
            // Configure the notification channel.
            mChannel.setDescription("Channel");
            mChannel.enableLights(true);
            mChannel.setName("Plop");
            // Sets the notification light color for notifications posted to this
            // channel, if the device supports this feature.
            mChannel.setLightColor(Color.RED);
            mChannel.enableVibration(true);
            mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
            mNotificationManager.createNotificationChannel(mChannel);
 
            Notification notification = new Notification.Builder(TrainingActivity.this)
                    .setContentTitle("Objet trouvé")
                    .setContentText("" + itemName)
                    .setSmallIcon(R.drawable.ic_menu_share)
                    .build();
 
            mNotificationManager.notify(1000, notification);
        }
        else
        {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
                    .setSmallIcon(R.drawable.ic_menu_share)
                    .setContentTitle("Objet trouvé")
                    .setContentText("" + itemName);
 
            // Creates an explicit intent for an Activity in your app
            Intent resultIntent = new Intent(this, TrainingActivity.class);
 
            // The stack builder object will contain an artificial back stack for the
            // started Activity.
            // This ensures that navigating backward from the Activity leads out of
            // your app to the Home screen.
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            // Adds the back stack for the Intent (but not the Intent itself)
            stackBuilder.addParentStack(TrainingActivity.class);
            // Adds the Intent that starts the Activity to the top of the stack
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
 
            mBuilder.setContentIntent(resultPendingIntent);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 
            // mNotificationId is a unique integer your app uses to identify the
            // notification. For example, to cancel the notification, you can pass its ID
            // number to NotificationManager.cancel().
            mNotificationManager.notify(101, mBuilder.build());
        }
    }
Bien cordialement, Jérémy