diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-02-18 20:58:45 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-02-18 20:58:45 +0100 |
commit | 87232ef8a03f421b765fbb6717d2d578a4965fd9 (patch) | |
tree | 82a314a341b322b318cad40bd6d8340000f58962 /src/main/java/de/pixart/messenger/services | |
parent | 5814744dca19a956a91020745b67cbb3b8191b6b (diff) |
after switching from forced foreground to foreground notification needs update
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/NotificationService.java | 2 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index d045879be..e039dbf36 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -1063,7 +1063,7 @@ public class NotificationService { } } - private void notify(int id, Notification notification) { + public void notify(int id, Notification notification) { final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); try { notificationManager.notify(id, notification); diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 3f9ac5f99..1735e455f 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -4,6 +4,7 @@ import android.Manifest; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.AlarmManager; +import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; @@ -1301,13 +1302,19 @@ public class XmppConnectionService extends Service { private void toggleForegroundService(boolean force) { final boolean status; if (force || mForceForegroundService.get() || (Compatibility.keepForegroundService(this)/* && hasEnabledAccounts()*/)) { - startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification()); + final Notification notification = this.mNotificationService.createForegroundNotification(); + startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, notification); + if (!mForceForegroundService.get()) { + mNotificationService.notify(NotificationService.FOREGROUND_NOTIFICATION_ID, notification); + } status = true; } else { stopForeground(true); status = false; } - mNotificationService.dismissForcedForegroundNotification(); //if the channel was changed the previous call might fail + if (!mForceForegroundService.get()) { + mNotificationService.dismissForcedForegroundNotification(); //if the channel was changed the previous call might fail + } Log.d(Config.LOGTAG, "ForegroundService: " + (status ? "on" : "off")); } |