Skip to content

Commit cd2cd7e

Browse files
committed
Update logic after more testing
1 parent ad68f9b commit cd2cd7e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,11 +1519,15 @@ private void exitForeground(){
15191519
synchronized (NOTIFICATION_LOCK) {
15201520
if (isForeground && !isPrimaryTransportConnected()) { //Ensure that the service is in the foreground and no longer connected to a transport
15211521
DebugTool.logInfo("SdlRouterService to exit foreground");
1522-
this.stopForeground(false); //false is used because some phones have issues when trying to clear the notification at the same time
1522+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
1523+
this.stopForeground(Service.STOP_FOREGROUND_DETACH);
1524+
}else{
1525+
stopForeground(false);
1526+
}
15231527
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
15241528
if (notificationManager!= null){
15251529
try {
1526-
notificationManager.cancel(FOREGROUND_SERVICE_ID);
1530+
notificationManager.cancelAll();
15271531
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
15281532
notificationManager.deleteNotificationChannel(SDL_NOTIFICATION_CHANNEL_ID);
15291533
}

0 commit comments

Comments
 (0)