几秒钟后清除通知 [英] Clearing notification after a few seconds
本文介绍了几秒钟后清除通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当你有帖子活动和开放手机收到新邮件通知时,状态栏上显示。很短的时间量之后,通知被删除。
When you have the Messages Activity open and the phone receives a new message a notification is shown on the status bar. After a short amount of time the notification is removed.
是否有可能做我的活动同样不使用定时器,几秒钟后,清除通知?
Is it possible to do the same for my activity without using a timer to clear the notification after a few seconds?
推荐答案
我不相信有使用NotificationManager只取消通知的方式,但你可以用一个简单的处理程序做到这一点。把一些code像您炒掉通知后这一权利。
I don't believe there's a way to use the NotificationManager only to cancel a notification, but you can do it with a simpler Handler. Put some code like this right after you fire your notification.
Handler h = new Handler();
long delayInMilliseconds = 5000;
h.postDelayed(new Runnable() {
public void run() {
mNotificationManager.cancel(YourNotificationId);
}
}, delayInMilliseconds);
这篇关于几秒钟后清除通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文