专栏首页技术小黑屋Fix Notification Switching Position Issue

Fix Notification Switching Position Issue

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

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Dump Table Structure in SQLite3

    Best answer to the question Use PRAGMA table_info

    技术小黑屋
  • Android NinePatch Attention

    I have got many crash report data about using NinePath Drwable. I put a .9.png f...

    技术小黑屋
  • WebView重写onJsAlert那些事

    本文主要将如何重写onJsAlert,让烦人的对话框变为无干扰的Toast,以及为什么onJsAlert只调用一次的问题.

    技术小黑屋
  • nano:基本操作

    JNingWei
  • TW洞见 | 敏捷回顾7步法

    Paulo和TC一直在收集整理关于敏捷回顾的任何想法和活动。在这篇内容里面,他们分享了7步法来帮助你组织你的下一次回顾。 Agenda structure: 1...

    ThoughtWorks
  • 基于图卷积网络的运动结构图像检索(CS CV)

    用于运动结构(SfM)的常规图像检索技术受到有效识别重复模式的局限,无法保证以高精度和高召回率创建足够的匹配对。在本文中,我们提出了一种基于图卷积网络(GCN)...

    gaowanting
  • 2019.8.15乘兴打Codeforces Round #569 (Div. 2)小记

    Recently, on the course of algorithms and data structures, Valeriy learned how t...

    glm233
  • The Note based on Data Structures and Algorithm Analysis in C CHAPTER 3 P1

    The Note based on Data Structures and Algorithm Analysis in C

    Chiptune
  • 使用SAP Transaction Launcher将ABAP Webdynpro嵌入到WebClient UI中

    THINK twice why you want to include an ABAP webdynpro component into CRM UI, as ...

    Jerry Wang
  • 使用SAP Transaction Launcher将ABAP Webdynpro嵌入到WebClient UI中

    THINK twice why you want to include an ABAP webdynpro component into CRM UI, as ...

    Jerry Wang

扫码关注云+社区

领取腾讯云代金券