Stop alarm when notification is dismissed
This commit is contained in:
parent
26f54e43e0
commit
81fd21be48
|
@ -70,6 +70,14 @@ class TimerService : Service() {
|
||||||
finishIntent,
|
finishIntent,
|
||||||
PendingIntent.FLAG_IMMUTABLE
|
PendingIntent.FLAG_IMMUTABLE
|
||||||
)
|
)
|
||||||
|
val stopIntent = Intent(applicationContext, StopTimer::class.java)
|
||||||
|
val pendingStop =
|
||||||
|
PendingIntent.getService(
|
||||||
|
applicationContext,
|
||||||
|
0,
|
||||||
|
stopIntent,
|
||||||
|
PendingIntent.FLAG_IMMUTABLE
|
||||||
|
)
|
||||||
builder.setContentText("Timer finished.")
|
builder.setContentText("Timer finished.")
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setProgress(0, 0, false)
|
.setProgress(0, 0, false)
|
||||||
|
@ -77,6 +85,7 @@ class TimerService : Service() {
|
||||||
.setContentIntent(finishPending)
|
.setContentIntent(finishPending)
|
||||||
.setChannelId(CHANNEL_ID_DONE)
|
.setChannelId(CHANNEL_ID_DONE)
|
||||||
.setCategory(NotificationCompat.CATEGORY_ALARM)
|
.setCategory(NotificationCompat.CATEGORY_ALARM)
|
||||||
|
.setDeleteIntent(pendingStop)
|
||||||
.priority = NotificationCompat.PRIORITY_HIGH
|
.priority = NotificationCompat.PRIORITY_HIGH
|
||||||
manager?.notify(NOTIFICATION_ID_DONE, builder.build())
|
manager?.notify(NOTIFICATION_ID_DONE, builder.build())
|
||||||
manager?.cancel(NOTIFICATION_ID_PENDING)
|
manager?.cancel(NOTIFICATION_ID_PENDING)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user