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。