Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Notification FLAG_AUTO_CANCEL not working

HI all

I want cancel notification on click using code below but some reason it always shows notification in Ongoing section in Notifications area and could not clear too ..

  NOTIFICATION_ID = NOTIFICATION_ID + 1;
  Intent intent1 = new Intent(this, MyClass.class);
  PendingIntent pii = PendingIntent.getActivity(this, 1, intent1, 0);
  Notification notification1 = new Notification(R.drawable.icon, "test",
    System.currentTimeMillis());

  notification1.setLatestEventInfo(this,
    "test", "test", pii);

  notification1.flags |= Notification.FLAG_AUTO_CANCEL;
  startForeground(NOTIFICATION_ID, notification1);

thanks

like image 433
Yousuf Qureshi Avatar asked Nov 28 '25 21:11

Yousuf Qureshi


1 Answers

FLAG_AUTO_CLEAR does not work with startForeground().

like image 176
CommonsWare Avatar answered Dec 01 '25 14:12

CommonsWare