Partager via


Notification.When Property

Definition

A timestamp related to this notification, in milliseconds since the epoch.

[Android.Runtime.Register("when")]
public long When { get; set; }
[<Android.Runtime.Register("when")>]
member this.When : int64 with get, set

Property Value

Attributes

Remarks

A timestamp related to this notification, in milliseconds since the epoch.

Default value: System#currentTimeMillis() 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:

<ul> <li>Notification of a new chat message should be stamped when the message was received.</li> <li>Notification of an ongoing file download (with a progress bar, for example) should be stamped when the download started.</li> <li>Notification of a completed file download should be stamped when the download finished.</li> <li>Notification of an upcoming meeting should be stamped with the time the meeting will begin (that is, in the future).</li> <li>Notification of an ongoing stopwatch (increasing timer) should be stamped with the watch's start time. <li>Notification of an ongoing countdown timer should be stamped with the timer's end time. </ul>

For apps targeting android.os.Build.VERSION_CODES#N and above, this time is not shown anymore by default and must be opted into by using android.app.Notification.Builder#setShowWhen(boolean)

Java documentation for android.app.Notification.when.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to