前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Fix Notification Switching Position Issue

Fix Notification Switching Position Issue

作者头像
技术小黑屋
发布2018-09-04 16:37:21
3600
发布2018-09-04 16:37:21
举报
文章被收录于专栏:技术小黑屋技术小黑屋

I once faced with a problem. I wrote a piece of code related with notifcation. Everything goes fine except one little issue. I found the ongoing notification switching order. My notification blinked each second. After Googling I found the reason and resolved the problem.

In my code I wrote like this

1

notification.when = System.currentTimeMillis();

That’s was the key point. For the notification the when timestamp should be fixed when an activity starts. And the default value is Now(which is the value of System.currentTimeMillis()).I used a fixed value and resovled the problem.

1

notification.when = TIMESTAMP_FIXED;

Now This is what Google says

A timestamp related to this notification, in milliseconds since the epoch. Default value: Now. Choose a timestamp that will be most relevant to the user. For most finite events, this corresponds to the time the event happened (or will happen, in the case of events that have yet to occur but about which the user is being informed). Indefinite events should be timestamped according to when the activity began. Some examples:

  • Notification of a new chat message should be stamped when the message was received.
  • Notification of an ongoing file download (with a progress bar, for example) should be stamped when the download started.
  • Notification of a completed file download should be stamped when the download finished.
  • Notification of an upcoming meeting should be stamped with the time the meeting will begin (that is, in the future).
  • Notification of an ongoing stopwatch (increasing timer) should be stamped with the watch’s start time.
  • Notification of an ongoing countdown timer should be stamped with the timer’s end time. Reference from http://developer.android.com/reference/android/app/Notification.html#when

Others

  • Pro Android UI
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Others
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档