From cd2cd7e5aeb7882cd4a6530c178885158e27c35e Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 19 Mar 2020 11:25:51 -0400 Subject: Update logic after more testing --- .../main/java/com/smartdevicelink/transport/SdlRouterService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java index efe9e2328..3313fd0f3 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java @@ -1519,11 +1519,15 @@ public class SdlRouterService extends Service{ synchronized (NOTIFICATION_LOCK) { if (isForeground && !isPrimaryTransportConnected()) { //Ensure that the service is in the foreground and no longer connected to a transport DebugTool.logInfo("SdlRouterService to exit foreground"); - this.stopForeground(false); //false is used because some phones have issues when trying to clear the notification at the same time + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + this.stopForeground(Service.STOP_FOREGROUND_DETACH); + }else{ + stopForeground(false); + } NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager!= null){ try { - notificationManager.cancel(FOREGROUND_SERVICE_ID); + notificationManager.cancelAll(); if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { notificationManager.deleteNotificationChannel(SDL_NOTIFICATION_CHANNEL_ID); } -- cgit v1.2.1