.addAction(wearAction);
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); NotificationManager mgr= (NotificationManager)getSystemService(NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O && mgr.getNotificationChannel(CHANNEL_WHATEVER)==null) { mgr.createNotificationChannel(new NotificationChannel(CHANNEL_WHATEVER, "Whatever", NotificationManager.IMPORTANCE_DEFAULT)); } NotificationCompat.Builder normal=buildNormal(); NotificationCompat.Action.Builder wearActionBuilder= new NotificationCompat.Action.Builder(android.R.drawable.ic_media_pause, getString(R.string.pause), buildPendingIntent(Settings.ACTION_DATE_SETTINGS)); NotificationCompat.Builder extended= new NotificationCompat.WearableExtender() .addAction(wearActionBuilder.build()) .extend(normal); NotificationManagerCompat.from(this).notify(NOTIFY_ID, extended.build()); finish(); }
.setContentIntent(viewPendingIntent) .setChannelId(id) .extend(new WearableExtender().addAction(action));
if (extendCheckBox.isChecked()) { final PendingIntent pendingIntent = PendingIntent.getActivity(this, 3, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); builder.extend(new NotificationCompat.WearableExtender().addAction(new NotificationCompat.Action(R.drawable.ic_stat_name, action3CheckBox.getText(), pendingIntent)));
wearableExtender.addAction(replyAction);
NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender(); extender.addAction( new NotificationCompat.Action( android.R.drawable.ic_media_previous, "Anterior", pitAnterior)); extender.addAction( new NotificationCompat.Action( android.R.drawable.ic_media_next, "Próximo", pitProximo)); extender.addAction( new NotificationCompat.Action( android.R.drawable.ic_media_play,
.setSound(sonido) .setContentIntent(pendingIntent) .extend(wearableExtender.addAction(action))
.setContentText("voice reply example.") .setChannelId(id) .extend(new WearableExtender().addAction(action));
public static void criarNotificacaoComResposta(Context ctx, int idNotificacao) { RemoteInput remoteInput = new RemoteInput.Builder(DetalheActivity.EXTRA_RESPOSTA_VOZ) .setLabel("Diga a resposta") .build(); PendingIntent pit = criarPendingIntent(ctx, "Notificação com resposta", idNotificacao); NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_acao_notificacao, "Responder", pit) .addRemoteInput(remoteInput) .build(); NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); Notification notificacao = new NotificationCompat.Builder(ctx) .setSmallIcon(R.drawable.ic_notificacao) .setContentTitle("Com resposta") .setContentText("Passe a página para responder") .setAutoCancel(true) .setDefaults(NotificationCompat.DEFAULT_ALL) .extend(wearableExtender.addAction(action)) .build(); NotificationManagerCompat nm = NotificationManagerCompat.from(ctx); nm.notify(idNotificacao, notificacao); }
private void addAction(NotificationCompat.Builder builder, int[] icons, int titleResId, PendingIntent operation) { builder.addAction(icons[0], getString(titleResId), operation); builder.extend(new NotificationCompat.WearableExtender().addAction( buildAction(icons[1], titleResId, operation))); }
private void addArchiveAllAction(WearableExtender wearableExtender, NotificationData notificationData) { int icon = resourceProvider.getWearIconArchive(); String title = resourceProvider.actionArchiveAll(); Account account = notificationData.getAccount(); ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences(); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent action = actionCreator.createArchiveAllPendingIntent(account, messageReferences, notificationId); NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon, title, action).build(); wearableExtender.addAction(archiveAction); }
private void addMarkAllAsReadAction(WearableExtender wearableExtender, NotificationData notificationData) { int icon = resourceProvider.getWearIconMarkAsRead(); String title = resourceProvider.actionMarkAllAsRead(); Account account = notificationData.getAccount(); ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences(); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent action = actionCreator.createMarkAllAsReadPendingIntent( account, messageReferences, notificationId); NotificationCompat.Action markAsReadAction = new NotificationCompat.Action.Builder(icon, title, action).build(); wearableExtender.addAction(markAsReadAction); }
private void addDeleteAction(WearableExtender wearableExtender, NotificationHolder holder) { int icon = resourceProvider.getWearIconDelete(); String title = resourceProvider.actionDelete(); MessageReference messageReference = holder.content.messageReference; int notificationId = holder.notificationId; PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId); NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build(); wearableExtender.addAction(deleteAction); }
private void addMarkAsSpamAction(WearableExtender wearableExtender, NotificationHolder holder) { int icon = resourceProvider.getWearIconMarkAsSpam(); String title = resourceProvider.actionMarkAsSpam(); MessageReference messageReference = holder.content.messageReference; int notificationId = holder.notificationId; PendingIntent action = actionCreator.createMarkMessageAsSpamPendingIntent(messageReference, notificationId); NotificationCompat.Action spamAction = new NotificationCompat.Action.Builder(icon, title, action).build(); wearableExtender.addAction(spamAction); }
private void addReplyAction(WearableExtender wearableExtender, NotificationHolder holder) { int icon = resourceProvider.getWearIconReplyAll(); String title = resourceProvider.actionReply(); MessageReference messageReference = holder.content.messageReference; int notificationId = holder.notificationId; PendingIntent action = actionCreator.createReplyPendingIntent(messageReference, notificationId); NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(icon, title, action).build(); wearableExtender.addAction(replyAction); }
private void addArchiveAction(WearableExtender wearableExtender, NotificationHolder holder) { int icon = resourceProvider.getWearIconArchive(); String title = resourceProvider.actionArchive(); MessageReference messageReference = holder.content.messageReference; int notificationId = holder.notificationId; PendingIntent action = actionCreator.createArchiveMessagePendingIntent(messageReference, notificationId); NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon, title, action).build(); wearableExtender.addAction(archiveAction); }
private void addMarkAsReadAction(WearableExtender wearableExtender, NotificationHolder holder) { int icon = resourceProvider.getWearIconMarkAsRead(); String title = resourceProvider.actionMarkAsRead(); MessageReference messageReference = holder.content.messageReference; int notificationId = holder.notificationId; PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId); NotificationCompat.Action markAsReadAction = new NotificationCompat.Action.Builder(icon, title, action).build(); wearableExtender.addAction(markAsReadAction); }
private void addDeleteAllAction(WearableExtender wearableExtender, NotificationData notificationData) { int icon = resourceProvider.getWearIconDelete(); String title = resourceProvider.actionDeleteAll(); Account account = notificationData.getAccount(); ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences(); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId); NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build(); wearableExtender.addAction(deleteAction); }