13

I'm currently working on an app with notification which are shown on a wear device. The notification contains an action binded onto the notification card (.setContentAction(0)).

enter image description here

Everything is working fine, except that it shows a confirmation message everytime someone clicks on the card.

enter image description here

Since the card gets updated as soon as someone clicks on it, it's not necessary to show a confirmation.

I already check the official documentation (https://developer.android.com/training/wearables/ui/confirm.html#show-confirmation) if there is a way to stop the confirmation, unfortunately I didn't find a solution so far.

Edit 09.07.2015

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                    .setGroup("GROUP")
                                    .setGroupSummary(false)
                                    .setAutoCancel(false)
                                    .setPriority(Notification.PRIORITY_HIGH)
                                    .setSmallIcon(R.drawable.ic_timer_white_48dp);

ArrayList<NotificationCompat.Action> actions = new ArrayList<>();
NotificationCompat.Action control = new NotificationCompat.Action.Builder(icon, null, pendingTimeIntent).build();

actions.add(control);

builder.extend(new NotificationCompat.WearableExtender().addActions(actions).setContentAction(0).setBackground(background));

NotificationManagerCompat notificationManager =
            NotificationManagerCompat.from(context);
notificationManager.notify(Constants.NOTIFICATION_ID_WEAR, builder.build());
Lukas
  • 2,544
  • 2
  • 18
  • 33

1 Answers1

0

you could try modify your constructor like:

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                    .setGroup("GROUP")
                                    .setGroupSummary(false)
                                    .setAutoCancel(false)
                                    .setPriority(Notification.PRIORITY_HIGH)
                                    .setShowWhen(true)                                                                                   
.setSmallIcon(R.drawable.ic_timer_white_48dp);

Note the line:

.setShowWhen(true);

And you can modify the flag of the Intent to false:

Intent intent = new Intent(this, ConfirmationActivity.class);
intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,
                ConfirmationActivity.SUCCESS_ANIMATION);
intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE,
                getString(R.string.msg_sent));
intent.putExtra(ConfirmationActivity.EXTRA_SHOW_WHEN, false);
startActivity(intent);

I don't know if it works properly, but I hope it gives you a clue.

  • 1
    This is not working, since NotificationCompat.WearableExtender().addActions(actions) only takes actions of the type NotificationCompat.Action, which just work with a pendingintents. It's not possible to add an extra to a pending intent. – Lukas Jul 10 '15 at 09:18
  • This doesn't work, since wearextender notification action pending intent set is not the confirmation activity intent , since this notification is triggered from phone app , not from wear app – Libin Jul 12 '15 at 21:48