Я использую компонент навигации Android от Androidx для создания ожидающих целей навигации.
В частности, я использую ожидающие намерения от Навигации для навигации из моих уведомлений.Однако невозможно отменить уведомление при нажатии на действие.
Оно работает правильно, если я щелкаю в самом уведомлении, потому что я использую setAutoCancel(true)
.Тем не менее, я не могу найти autoCancel
для действий по уведомлению.
Это мой код:
// Build Pending Intent
val statusPendingIntent = NavDeepLinkBuilder(context)
.setGraph(R.navigation.navigation)
.setDestination(R.id.status)
.createPendingIntent()
// Build Notification Action
val statusAction = NotificationCompat.Action(
R.drawable.menu_icon_status,
resources.getString(R.string.menuitem_status),
statusPendingIntent
)
// Build Notification
val notificationBuilder = NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(someOtherIntent) // This intent cancels the notification as it has "AutoCancel"
.addAction(statusAction) // This is the notification action. If I click on it, the notification is not cancelled
.setAutoCancel(true) // AutoCancel itself, closes the notification on tap
У кого-нибудь тоже была эта проблема?