Whenever you use addAction() in NotificationCompat.WearableExtender , you do not actually expand your actions (despite the name), but rather divide them into two lists: one for the phone and one for the wearable.
- Actions added to the original
NotificationCompat.Builder are displayed on the PDA. - Actions added to WearableExtender are displayed on the Android Wear device.
See Note Wearable-only Actions :
If you want the actions available on the wearable to be different from those on the PDA, then use WearableExtender.addAction() . Once you add an action using this method, the wearable does not display any other actions added using NotificationCompat.Builder.addAction() . That is, only actions added using WearableExtender.addAction() are wearable, and they do not appear on the PDA.
Therefore, in order to have actions only for laptop computers, add them before , creating an expander. And to have wearing-only actions, add them to the expander. If you use an expander and want to repeat the steps on both devices, you should add them to both (although perhaps there is a possibility to copy them?).
For instance:
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("The title") .setContentText("This is the text") .setContentIntent(pendingIntent); // Handheld-only actions. notificationBuilder.addAction(drawable1, "In Both", pendingIntent); notificationBuilder.addAction(drawable2, "Only in phone", pendingIntent); // Wearable-only actions. NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); wearableExtender.addAction(new NotificationCompat.Action.Builder(drawable2, "In Both", pendingIntent).build()); wearableExtender.addAction(new NotificationCompat.Action.Builder(drawable3, "Only in wearable", pendingIntent).build()); notificationBuilder.extend(wearableExtender); // Build and show notification. NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.notify(notificationId, notificationBuilder.build());
Also
- If you create a
WearableExtender but donβt add any actions to it, then the actions from the original notification are used. - The "content intention" from the handheld device is always present on the watch with the text "Open by phone." I have not found a way to disable this for hours only.
source share