2

When building my notification out this does not work to cancel the notification:

NotificationCompat.Builder notificationBuilder =
                new NotificationCompat.Builder(getApplicationContext())
                        .setSmallIcon(R.drawable.small_icon)
                        .setLargeIcon(largeIcon).setContentTitle(msg).setAutoCancel(true)
                        .setDefaults( Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS);
        ;

all i want to do is after the user has viewed the notification it should auto cancel. I also tried cancelling the notification right away to see if its even cancelable from the desktop head unit but it wont work. I tried the following:

NotificationManagerCompat msgNotificationManager =
                NotificationManagerCompat.from(this);
        msgNotificationManager.cancel(myid);

this does not cancel the notification. When im using the device all this works fine, just android auto wont allow the user to dismiss the notification, how can i do this ?

UPDATE: I ALSO TRIED THE FOLLOWING:

    PendingIntent notifyPIntent =
                PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0);

NotificationCompat.Builder notificationBuilder =
                new NotificationCompat.Builder(getApplicationContext())
                        .setSmallIcon(R.drawable.small_icon)
                        .setLargeIcon(largeIcon).setContentTitle(msg).setAutoCancel(true)
                        .setDefaults( Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS)
                .setContentIntent(notifyPIntent);

BUT it does not help, same issue.

j2emanue
  • 60,549
  • 65
  • 286
  • 456

0 Answers0