Android 通知不会消失(即使使用 Auto_Cancel)
我有不同的通知,每个通知都有与之关联的不同捆绑包/活动。我的问题是它们一旦点击就不会消失。不过,它们并没有受到持续的通知,并且“清除”可以消除它们。下面是我的代码。任何想法将不胜感激。 :)
private void showNotification(Bundle b){
CharSequence myText = b.getString("notifStr");
Notification notification = new Notification(R.drawable.stat_sample, myText,System.currentTimeMillis());
Intent i = new Intent(myContext, NewPlace.class);
i.setAction(Intent.ACTION_VIEW + Integer.toString(b.getInt("id")));
i.putExtras(b);
PendingIntent contentIntent = PendingIntent.getActivity(myContext, 0, i, 0);
notification.defaults |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(myContext, myText,myText, contentIntent);
notifMan.notify(b.getInt("id"), notification);
}
I have different notifications that each have a different bundle/activity associated with them. My problem is that they don't disappear once clicked. They aren't under ongoing notifications though and "clear" gets rid of them. Bellow is my code. Any thoughts would be greatly appreciated. :)
private void showNotification(Bundle b){
CharSequence myText = b.getString("notifStr");
Notification notification = new Notification(R.drawable.stat_sample, myText,System.currentTimeMillis());
Intent i = new Intent(myContext, NewPlace.class);
i.setAction(Intent.ACTION_VIEW + Integer.toString(b.getInt("id")));
i.putExtras(b);
PendingIntent contentIntent = PendingIntent.getActivity(myContext, 0, i, 0);
notification.defaults |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(myContext, myText,myText, contentIntent);
notifMan.notify(b.getInt("id"), notification);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试更改:
通知
文档(标志)
try changing:
to
Notification Documentation (Flags)
你应该尝试
You should try