I have found one answer here:
Pin Notification to top of notification area
Does anyone known what the Vaiden's answer means?
notification.when = previousTimestamp;
How to get the "previousTimestamp"?
Thanks.
I have found one answer here:
Pin Notification to top of notification area
Does anyone known what the Vaiden's answer means?
notification.when = previousTimestamp;
How to get the "previousTimestamp"?
Thanks.
Vaiden means to make up timestamps for all of your notifications in the order you want them to appear in. Give a more recent timestamp for the ones that you want to have appear up top. The key point is that in the following example, previousTimestamp
does not change, as opposed to constantly updating it with the current system time on every refresh (in the case of the question you are referring to, every 3 seconds).
set the following on all of your notifications:
myNotification.when = previousTimestamp;
not
myNotification.when = System.currentTimeMillis();
EDIT: Besides Vaiden's method, there are two things you can do to move your notifications up.
You can set the following two flags on your notification to make it ongoing, keeping it above non-ongoing notifications. Keep in mind that notifications that the user would expect to be able to clear, such as an email notification, should not use this method.
myNotification.flags |=
Notification.FLAG_ONGOING_EVENT;
myNotification.flags |= Notification.FLAG_NO_CLEAR;
You can set the notification priority to a higher level of you are developing for Android 4.1 Jelly Bean and above. They are MAX, HIGH, DEFAULT, LOW, and MIN. If your app runs below Jelly Bean as well, then the priority is just default. See http://developer.android.com/design/patterns/notifications.html for more details on what priority is appropriate for which type of notification, but just remember, as with the ongoing flag, don't abuse the high priority setting.
NotificationCompat.setPriority(PRIORITY_MAX);