corazza
corazza

Reputation: 32354

Button/Action not appearing on Wear notification

I'm trying to build an Android application that sends a notification to an Android Wear device.

The notification needs to have a content action set, so that the user can directly activate the action by clicking on the button displayed in the notification.

However, using the below code, the action appears on the next page, just like a regular action, and not on the notification:

Context context = getApplicationContext();

// Create an intent for the reply action
Intent actionIntent = new Intent(this, getClass());

PendingIntent actionPendingIntent =
        PendingIntent.getActivity(this, 0, actionIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

// Create the action
NotificationCompat.Action action =
        new NotificationCompat.Action.Builder(R.drawable.common_signin_btn_icon_dark, "ActionTitle", actionPendingIntent).build();

NotificationCompat.Builder builder =
        new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.common_signin_btn_icon_dark)
                .setContentTitle("Title")
                .setContentText("Context Text")
                .addAction(action)
                .extend(new NotificationCompat.WearableExtender()
                        .setContentAction(0));

// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
        NotificationManagerCompat.from(this);

// Build the notification and issues it with notification manager.
notificationManager.notify(0, builder.build());

This is how it looks:

enter image description here

After swiping:

enter image description here

It is supposed to all be on a single page, with the Action button imbedded into the notification, like this:

enter image description here

What am I doing wrong?

Upvotes: 0

Views: 969

Answers (1)

Related Questions