Android Notification bar Bounce Problem solving method _android

Source: Internet
Author: User

Once encountered such a problem, in my code to use the notification bar, everything is normal, but is in the notification bar in progress of my program is always jumping up and down, a flash. Feel the user experience is very bad, so Google, found a solution.

In my code, that's what I wrote.

Copy Code code as follows:

Notification.when = System.currenttimemillis ();

This is the crux of the problem, and for notifications, when this attribute value should be fixed at the start of an activity. If it is not fixed, the default value is used, and the default value is the current time, which is the value of System.currenttimemillis (). So using a custom fixed value can solve the problem.

Copy Code code as follows:

Final long timestamp_fixed = 1234567890l;
Notification.when = timestamp_fixed;

Here's how Google describes how to use the notification when.

Copy Code code as follows:

A timestamp related to that notification, in milliseconds since the epoch. Default Value:now. Choose a timestamp that would be most relevant to the user. For most finite events, this is corresponds to the "time" of the event happened (or would happen, in the case of events that have Y ET 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 is stamped when the message was received.
Notification of ongoing file download (with a progress bar, for example) should is stamped when the download.
Notification of a completed file download should is stamped when the download finished.
Notification of a upcoming meeting should being stamped with the "time" of the meeting would begin (that's, in the future).
Notification of an ongoing stopwatch (increasing timer) should is stamped with the watch ' s start time.
Notification of an ongoing countdown timer should is stamped with the timer ' s.

Reference

Http://developer.android.com/reference/android/app/Notification.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.