有什么方法可以在通知上使用setTimeoutAfter()撤消吗?

时间:2019-01-29 23:53:57

标签: android

是否可以删除通知超时?

我正在显示电子邮件通知,并且包括一个删除电子邮件的操作,然后使用简单的“撤消”通知来更新该通知,并且我已在此新通知中使用setTimeOut(5000)在5秒钟后将其自身关闭

当您点击“撤消”时,会出现问题,它将带回原始通知,然后在几秒钟后将其清除。重新创建原始通知时,我没有设置setTimeOut,但是我必须使用相同的通知ID。

包含撤消通知的代码。

我尝试设置负超时和0超时,但是当原来的5秒钟用完时,它仍然会清除。

NotificationCompat.Builder builder = new 
NotificationCompat.Builder(context, "channel");
builder.setContentTitle("Message deleted");
builder.setSmallIcon(R.drawable.ic_folder_notif);
builder.setColor(ContextCompat.getColor(context, R.color.primary));
builder.setGroup(message.getFolderId());
builder.setSubText(folderName);
builder.addAction(R.drawable.undo, "Undo", undeletePendingIntent);
builder.setTimeoutAfter(5000);
NotificationManagerCompat.from(context).notify(notificationId, builder.build());

0 个答案:

没有答案