From cf93a172b9238e6612b778c7ab76013acebf0ef8 Mon Sep 17 00:00:00 2001 From: Julian Winkler Date: Wed, 3 Sep 2025 19:22:00 +0200 Subject: [PATCH] Service.stopForeground(): actually cancel the notification --- src/api-impl/android/app/Service.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/api-impl/android/app/Service.java b/src/api-impl/android/app/Service.java index e77d5615..c0581611 100644 --- a/src/api-impl/android/app/Service.java +++ b/src/api-impl/android/app/Service.java @@ -7,6 +7,8 @@ import android.os.IBinder; public abstract class Service extends ContextWrapper { + private int notification_id; + /* HACK for InputMethodService */ public Service(Context baseContext) { super(baseContext); @@ -33,14 +35,17 @@ public abstract class Service extends ContextWrapper { public void startForeground(int id, Notification notification) { System.out.println("startForeground(" + id + ", " + notification + ") called"); + this.notification_id = id; } public void stopForeground(boolean remove) { System.out.println("stopForeground(" + remove + ") called"); + if (remove) + new NotificationManager().cancel(notification_id); } public void stopForeground(int remove) { - System.out.println("stopForeground(" + remove + ") called"); + stopForeground(remove == 1); } public Application getApplication() {