曾经遇到过这样的问题,在我的代码中使用了通知栏,一切都正常,但是就是正在进行的通知栏中属于我的程序的那一条总是上下跳来跳去,一闪一闪的。感觉用户体验很不好,于是google一下,找到了解决方法。
在我的代码,我是这样写的。
这就是问题的关键,对于通知来说,when这个属性值应该在activity一启动的时候就应该固定。如果没有固定,就会使用默认的值,默认的值就是当前的时间,即system.currenttimemillis()的值。因此使用一个自定义的固定值就可以解决问题。
以下如google介绍如何使用notification的when的说明。
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
如对本文有疑问, 点击进行留言回复!!
LongClick原理、上下文菜单原理、EditText长按弹窗原理、WebView长按弹窗自定义、修复WebView全选重复bug ———————————————— 版权声明:本文为CSDN博主「
JobScheduler 实现 特定时间,特定条件(系统空闲,电池电量,磁盘空间 ……)下执行任务
温习Android基础知识——《第一行代码(第三版)》读书笔记 Chapter 10 Service
网友评论