new NotificationCompat.WearableExtender() .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(); }
.setStyle(big); NotificationCompat.Builder twoPages= new NotificationCompat.WearableExtender() .addPage(bigPage.build()) .extend(normal);
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(statusBarNotification.getNotification()); List<NotificationCompat.Action> actions = wearableExtender.getActions(); Log.d(Constants.TAG, "NotificationUtils replyToNotification actions.size: " + actions.size() + " \\ isEmpty: " + actions.isEmpty());
ctx.getResources(), R.mipmap.ic_launcher); NotificationCompat.WearableExtender extensaoWear = new NotificationCompat.WearableExtender().setBackground(imgBackground); NotificationCompat.InboxStyle estilo = new NotificationCompat.InboxStyle() .setBigContentTitle(qtdeDeMensagens)
.setSmallIcon(R.mipmap.ic_launcher); NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender(); extender.addAction( new NotificationCompat.Action(
.setContentIntent(viewPendingIntent) .setChannelId(id) .extend(new WearableExtender().addAction(action));
new NotificationCompat.WearableExtender() .setHintHideIcon(true) .setBackground(BitmapFactory.decodeResource(getResources(),
.extend(new NotificationCompat.WearableExtender() .addPages(notificationPages)) .build();
.setContentText("voice reply example.") .setChannelId(id) .extend(new WearableExtender().addAction(action));
Notification notification = notificationBuilder.extend(new WearableExtender()).build();
public static void criarNotificacaoComPaginas(Context ctx, int idNotificacao) { PendingIntent pit = criarPendingIntent(ctx, "Notificação com páginas", idNotificacao); NotificationCompat.Builder notificacaoPrincipal = new NotificationCompat.Builder(ctx) .setSmallIcon(R.drawable.ic_notificacao) .setContentTitle("Com páginas") .setContentText("Essa é a primeira página") .setAutoCancel(true) .setContentIntent(pit) .setDefaults(NotificationCompat.DEFAULT_ALL); NotificationCompat.BigTextStyle estiloDePagina = new NotificationCompat.BigTextStyle() .setBigContentTitle("Segunda página") .bigText("Um texto qualquer que você queira colocar na segunda página"); Notification notificacaoPag2 = new NotificationCompat.Builder(ctx) .setStyle(estiloDePagina) .build(); Notification notificacaoCom2Paginas = new NotificationCompat.WearableExtender() .addPage(notificacaoPag2) .extend(notificacaoPrincipal) .build(); NotificationManagerCompat nm = NotificationManagerCompat.from(ctx); nm.notify(idNotificacao, notificacaoCom2Paginas); }
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); }
@Override public WearableExtender clone() { WearableExtender that = new WearableExtender(); that.mActions = new ArrayList<Action>(this.mActions); that.mFlags = this.mFlags; that.mDisplayIntent = this.mDisplayIntent; that.mPages = new ArrayList<Notification>(this.mPages); that.mBackground = this.mBackground; that.mContentIcon = this.mContentIcon; that.mContentIconGravity = this.mContentIconGravity; that.mContentActionIndex = this.mContentActionIndex; that.mCustomSizePreset = this.mCustomSizePreset; that.mCustomContentHeight = this.mCustomContentHeight; that.mGravity = this.mGravity; return that; }
private static void extendWearable(NotificationCompat.Builder builder, int type, int color, boolean autoNotify, Context context) { int bmdRes = R.drawable.wear_reminder; if (autoNotify) { bmdRes = R.drawable.wear_auto_notify; } else { if (type == Thing.HABIT) { bmdRes = R.drawable.wear_habit; } else if (type == Thing.GOAL) { bmdRes = R.drawable.wear_goal; } } BitmapDrawable bmd = (BitmapDrawable) ContextCompat.getDrawable(context, bmdRes); Bitmap bm = BitmapUtil.createLayeredBitmap(bmd, color); builder.extend(new NotificationCompat.WearableExtender().setBackground(bm)); }
private static NotificationCompat.Action getWearReplyAction(Notification n) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(n); for (NotificationCompat.Action action : wearableExtender.getActions()) { if(action.getRemoteInputs() != null) { for (int x = 0; x < action.getRemoteInputs().length; x++) { RemoteInput remoteInput = action.getRemoteInputs()[x]; if (isKnownReplyKey(remoteInput.getResultKey())) return action; else if (remoteInput.getResultKey().toLowerCase().contains(INPUT_KEYWORD)) return action; } } } return null; }
public static ArrayList<Action> getActions(Notification n, String packageName, ArrayList<Action> actions) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(n); if (wearableExtender.getActions().size() > 0) { for (NotificationCompat.Action action : wearableExtender.getActions()) { Log.d(Constants.TAG, "NotificationUtils getActions action: " + action.getTitle().toString()); actions.add(new Action(action, packageName, action.title.toString().toLowerCase().contains(REPLY_KEYWORD))); } } return actions; }
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 addWearActions(Builder builder, Account account, NotificationHolder holder) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addReplyAction(wearableExtender, holder); addMarkAsReadAction(wearableExtender, holder); if (isDeleteActionAvailableForWear()) { addDeleteAction(wearableExtender, holder); } if (isArchiveActionAvailableForWear(account)) { addArchiveAction(wearableExtender, holder); } if (isSpamActionAvailableForWear(account)) { addMarkAsSpamAction(wearableExtender, holder); } builder.extend(wearableExtender); }
public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); }