开发者

Android Notifications not disappearing (Even with Auto_Cancel)

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.def开发者_JAVA技巧aults |= Notification.FLAG_AUTO_CANCEL;

    notification.setLatestEventInfo(myContext, myText,myText, contentIntent);

    notifMan.notify(b.getInt("id"), notification);
}


try changing:

notification.defaults |= Notification.FLAG_AUTO_CANCEL;

to

notification.flags |= Notification.FLAG_AUTO_CANCEL;

Notification Documentation (Flags)

public int defaults

Since: API Level 1 Specifies which values should be taken from the defaults. To set, OR the desired from DEFAULT_SOUND, DEFAULT_VIBRATE, DEFAULT_LIGHTS. For all default values, use DEFAULT_ALL.


You should try

notification.flags |= Notification.FLAG_AUTO_CANCEL;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜