【发布时间】:2013-07-13 09:56:31
【问题描述】:
如何在通知栏中创建一个 5 秒后消失的通知? 例如;这是通知代码:
Intent intent = new Intent(this, NotificationReceiver.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
// Build notification
// Actions are just fake
Notification noti = new Notification.Builder(this)
.setContentTitle("Notification")
.setContentText("This is a notification that didsappears in 5 seconds")
.setSmallIcon(R.drawable.icon)
.setContentIntent(pIntent)
.addAction(R.drawable.icon)
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, noti);
从这段代码开始,我如何创建 5 秒后消失的通知?
【问题讨论】:
-
只需在五秒后取消通知。
-
是的,这就是我想做的,但我不知道代码放在哪里以及代码使用什么..
标签: android notifications statusbar android-notifications