如何解决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,i,0);
notification.defaults |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(myContext,contentIntent);
notifMan.notify(b.getInt(\"id\"),notification);
}
解决方法
你应该试试
notification.flags |= Notification.FLAG_AUTO_CANCEL;
,尝试更改:
notification.defaults |= Notification.FLAG_AUTO_CANCEL;
至
notification.flags |= Notification.FLAG_AUTO_CANCEL;
通知文档(标志)
public int默认值
从以下版本开始:API Level 1指定
值应取自
默认值。设置,或所需从
DEFAULT_SOUND,DEFAULT_VIBRATE,
DEFAULT_LIGHTS。对于所有默认
值,请使用DEFAULT_ALL。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。