use*_*394 5 android android-notifications
我一直在寻找这个问题差不多一天,我在这里关注Android Notification的例子:http://www.vogella.com/articles/AndroidNotifications/article.html.它运作良好,我可以发送Notification.问题是,当我点击通知时,即使我设置了它也不会消失:
setAutoCancel(true) 和 notification.flags |= Notification.FLAG_AUTO_CANCEL
更新:这是我的代码
Intent intent = new Intent(MyNotification.this, NotificationReceiver.class);
PendingIntent pIntent = PendingIntent.getActivity(
MyNotification.this, 0, intent, 0);
NotificationCompat.Builder builder =
new NotificationCompat.Builder(MyNotification.this)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.addAction(R.drawable.ic_launcher, "Call", pIntent)
.addAction(R.drawable.ic_launcher, "More", pIntent)
.addAction(R.drawable.ic_launcher, "And more", pIntent)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject");
Notification noti = builder.build();
noti.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, noti);
Run Code Online (Sandbox Code Playgroud)
问题来自哪里?谢谢你的帮助.
用这个..
notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL
| 归档时间: |
|
| 查看次数: |
12969 次 |
| 最近记录: |