Reputation: 101
I'm trying to add to the android push notification the timestamp when it was created. What is the best manner to implement that?
Thanks!
Upvotes: 5
Views: 5754
Reputation: 1085
According to the Notification.Builder
documentation you can simply use the following:
setWhen(long when)
setShowWhen(boolean show);
When you set a timestamp with the setWhen(long when)
method, setShowWhen
is true
by default, so calling setShowWhen(true)
is optionally.
Upvotes: 10
Reputation: 453
From API Level 17 onwards, you can use setShowWhen(true)
public Notification.Builder setShowWhen (boolean show)
Added in API level 17 Control whether the timestamp set with setWhen is shown in the content view.
http://developer.android.com/reference/android/app/Notification.Builder.html#setShowWhen(boolean)
Upvotes: 0