我有不同的通知,每个通知都有与之关联的不同捆绑/活动。我的问题是,点击后它们不会消失。他们并没有持续通知,而且“清楚”地摆脱了它们。贝娄是我的代码。任何想法将不胜感激。 :)
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);
}
答案 0 :(得分:2)
尝试改变:
notification.defaults |= Notification.FLAG_AUTO_CANCEL;
到
notification.flags |= Notification.FLAG_AUTO_CANCEL;
通知文件(标志)
public int defaults
从:API级别1指定哪个 值应取自 默认值。设置,或者从中设置 DEFAULT_SOUND,DEFAULT_VIBRATE, DEFAULT_LIGHTS。对于所有默认值 值,使用DEFAULT_ALL。
答案 1 :(得分:1)
你应该试试
notification.flags |= Notification.FLAG_AUTO_CANCEL;