два вопроса:Отклонить Android уведомления Wear после действия и не маленький значок
- Как я могу отклонить уведомление после пользователь нажал кнопку действия
- Маленький значок всегда не отображается зеленый Android логотип
Мой код:
int notificationId = 001;
// Reply action
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("google.navigation:///?q=48.193479,11.569957&mode=w"));
PendingIntent actionPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Create the action
Notification.Action action =
new Notification.Action.Builder(R.drawable.map_white,
"Open Navigation", actionPendingIntent)
.build();
Notification notification =
new Notification.Builder(getApplicationContext())
.setPriority(Notification.PRIORITY_HIGH)
.setSmallIcon(R.drawable.map_icon_notification)
.setContentTitle("Navigation Notification")
.setContentText("Please swipe left to start navigation.")
.extend(new Notification.WearableExtender().addAction(action).setBackground(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.background_notification)))
.setAutoCancel(true)
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(ListenerService.this);
notificationManager.notify(notificationId, notification);
В общем, если у вас есть два отдельных вопроса, то лучше размещать их отдельно на стек Переполнение. Это помогает другим людям легче находить их в будущем :-) – stkent
@stkent Я помню об этом! Благодаря! – Philipp