Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a notification with an undo button like gmail?

I want to implement a notification like this:

enter image description here

I know that I can use custom layout notification and set an onClickPendingIntent. But, is this the best option? If it is not, what is it? And if it is, how can I mimic the left square with the icon? Measures, color, etc.

like image 386
Brais Gabin Avatar asked Aug 09 '14 10:08

Brais Gabin


1 Answers

Yes, that is the best option. Use RemoteViews to create your custom layout, and make sure to use onClickPendingIntent and not setContentIntent for UNDO action. If you use the second approach notification bar gets minimized and that's not something you want if you want to seamlessly update the notification once again after user presses UNDO like Gmail does.

If you want to align your icon with non-custom notifications use following dimensions: https://www.google.com/design/spec/patterns/notifications.html#notifications-content

like image 70
njosa Avatar answered Oct 07 '22 23:10

njosa