Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Add Timestamp On The Android Notification?

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!

like image 329
Matheus Faleiro Avatar asked May 09 '16 14:05

Matheus Faleiro


People also ask

How do I check my notification time?

Open Settings app on your Android phone. Go to “Apps and notifications” and then tap on “Notifications”. Now tap on “Advanced” and finally tap on “Notification history“. On some phones it will be visible outside of the advanced category.


1 Answers

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.

like image 153
Jeffalee Avatar answered Nov 15 '22 05:11

Jeffalee