0

What's the correct way to set a clickable button in a rich notification in Honeycomb? Like the media play buttons shown here (which I think are from the Music app) -

http://androidcommunity.com/google-details-honeycombs-notification-bar-20110202/

It's not setSmallIcon() in Notification.Builder. That call sets the icon that identifies the app in the status bar.

Looking at Notification.Builder, do we need to call setContent() with a RemoteViews object?

Programmer Bruce
  • 64,977
  • 7
  • 99
  • 97
suzannea
  • 105
  • 1
  • 7

1 Answers1

4

Correct you need to create a RemoteViews object which allows you to specify PendingIntents for individual widgets within it by calling setOnClickPendingIntent. You can then set this RemoteViews as the Notification's contentView:

RemoteViews layout = new RemoteViews(getPackageName(), R.layout.notification);
notification.contentView = layout;
layout.setOnClickPendingIntent(R.id.notification_button, getDialogPendingIntent("Tapped the 'dialog' button in the notification."));

See the Honeycomb Gallery for a full example of this.

crafty
  • 2,730
  • 1
  • 21
  • 10