diff options
Diffstat (limited to 'android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java')
-rwxr-xr-x | android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java index c6e9ce3ef..59daf2050 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java @@ -108,10 +108,13 @@ public class SdlService extends Service { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.createNotificationChannel(channel); - Notification serviceNotification = new Notification.Builder(this, channel.getId()) + Notification.Builder builder = new Notification.Builder(this, channel.getId()) .setContentTitle("Connected through SDL") - .setSmallIcon(R.drawable.ic_sdl) - .build(); + .setSmallIcon(R.drawable.ic_sdl); + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + builder.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_IMMEDIATE); + } + Notification serviceNotification = builder.build(); startForeground(FOREGROUND_SERVICE_ID, serviceNotification); } } |