Partage
  • Partager sur Facebook
  • Partager sur Twitter

Supprimer la notification sur un action button

    27 février 2021 à 13:46:00

    Bonjour,

    Comment supprimer la notification quand on clique sur l'action button ?

    En effet, en même temps que d'ouvrir le site je voudrais que la notification soit supprimer car on a plus besoin une fois qu'on a cliqué.

    public void shopNotification(int shopId, String shopName, String message) {
            Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
            notificationIntent.setData(Uri.parse("website.com" + shopId));
            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    
            // Notification Icon
            Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.shop_notification_logo);
    
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setContentTitle("Boutique à proximité : " + shopName)
                    .setContentText(message)
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
                    .setShowWhen(true)
                    .setLargeIcon(myBitmap)
                    .addAction(R.drawable.ic_launch, "Voir la boutique", pendingIntent)
                    .setPriority(NotificationCompat.PRIORITY_DEFAULT);
    
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(2, mBuilder.build());
        }



    -
    Edité par Pytchoun 27 février 2021 à 13:47:03

    • Partager sur Facebook
    • Partager sur Twitter

    Supprimer la notification sur un action button

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown