我有一个具有前端通知的前台服务的警报应用程序,该通知有两个操作,其中一个向服务发送意图并可以根据应用程序配置打开活动.
问题是,当我点击将意图发送到服务的操作时,通知不会隐藏.当intent打开Activity时,似乎不会发生这种情况
我不想要没有通知的前台服务,我只是希望它在将意图发送到服务时将其隐藏回通知抽屉
这是代码:
NotificationCompat.Builder(mAlarmApplication, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification_alarm)
.setAutoCancel(false)
.setOngoing(true)
.setVibrate(LongArray(0))
.setContentTitle("Title")
.setContentText("Content")
.addAction(0, dismissActionText, dismissPendingIntent)
.setCategory(NotificationCompat.CATEGORY_ALARM)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentIntent(alarmScreenPendingIntent)
.setFullScreenIntent(alarmScreenPendingIntent, true)
Run Code Online (Sandbox Code Playgroud)
以下是应用https://play.google.com/store/apps/details?id=com.garageapp.alarmchallenges的链接.
警报启动时出现问题,我当前的解决方案是更新旧的抬头通知,使用新的抬头通知,但是UX不是很好,因为在Android 8+上通知新通知会弹出老化