Jelly Bean added support for expandable status notification. According to http://developer.android.com/about/versions/jelly-bean.html:
In addition to the templated styles, you can create your own notification styles using any remote View.
How do do this? I believe to do this you need to create a custom Notification.Style. It's an abstract class so I it needs to be extended. I haven't been able to find any documentation on which parts need to be extended.
This SO question gives a good example of how to use the notificaiton.builder for basic notificaitons, I'm using this as a starting point. Adding
.setContent(new RemoteViews(getPackageName(), R.layout.notification))
adds a custom view for basic notifications, but it's not expandable.
You need to create your own RemoteViews
, then indicate that you want the expanded content to inherit your custom RemoteViews
.
RemoteViews expandedView = new RemoteViews(YOUR CONTEXT.getPackageName(), YOUR CUSTOM LAYOUT);
Notification notification = mBuilder.build();
notification.bigContentView = expandedView;
Note that bigContentView
is what you're looking for. mBuilder
is a Notification.Builder object.
There's a good tutorial here on how to do it and how to create your own layout too.
Basically you need to create a remoteView with your layout and then set it as bigContentView in the Notification object. Btw make sure you also add the reguler contentView because the OS will use the smaller contentView in some cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With