Android中通知栏跳动问题解决方法
曾经遇到过这样的问题,在我的代码中使用了通知栏,一切都正常,但是就是正在进行的通知栏中属于我的程序的那一条总是上下跳来跳去,一闪一闪的。感觉用户体验很不好,于是google一下,找到了解决方法。
在我的代码,我是这样写的。
notification.when = system.currenttimemillis();
这就是问题的关键,对于通知来说,when这个属性值应该在activity一启动的时候就应该固定。如果没有固定,就会使用默认的值,默认的值就是当前的时间,即system.currenttimemillis()的值。因此使用一个自定义的固定值就可以解决问题。
final long timestamp_fixed = 1234567890l;
notification.when = timestamp_fixed;
以下如google介绍如何使用notification的when的说明。
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
http://developer.android.com/reference/android/app/notification.html#when
上一篇: 查看进程权限
推荐阅读
-
Android中ImageView无法居中的问题解决方法
-
深入android中The connection to adb is down的问题以及解决方法
-
Android编程中TextView宽度过大导致Drawable无法居中问题解决方法
-
Android编程中聊天页面背景图片、标题栏由于键盘引起问题的解决方法
-
Vue中android4.4不兼容问题的解决方法
-
Android编程开发ScrollView中ViewPager无法正常滑动问题解决方法
-
Android中ImageView无法居中的问题解决方法
-
Android中fragment嵌套fragment问题解决方法
-
Android开发 RadioButton使用中遇到的问题与解决方法
-
Android开发中遇到端口号占用问题解决方法