diff --git a/android/src/main/java/com/tanguyantoine/react/MusicControlNotification.java b/android/src/main/java/com/tanguyantoine/react/MusicControlNotification.java index 74ba89fa..4473a582 100644 --- a/android/src/main/java/com/tanguyantoine/react/MusicControlNotification.java +++ b/android/src/main/java/com/tanguyantoine/react/MusicControlNotification.java @@ -234,20 +234,17 @@ public IBinder onBind(Intent intent) { public void forceForeground() { // API lower than 26 do not need this work around. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - Intent intent = new Intent(MusicControlNotification.NotificationService.this, - MusicControlNotification.NotificationService.class); - // service has already been initialized. - // startForeground method should be called within 5 seconds. - ContextCompat.startForegroundService(MusicControlNotification.NotificationService.this, intent); + try { + Intent intent = new Intent(MusicControlNotification.NotificationService.this, + MusicControlNotification.NotificationService.class); + // service has already been initialized. + // startForeground method should be called within 5 seconds. + ContextCompat.startForegroundService(MusicControlNotification.NotificationService.this, intent); - if (MusicControlModule.INSTANCE == null) { - try { + if (MusicControlModule.INSTANCE == null) { MusicControlModule.INSTANCE.init(); - } catch (Exception ex) { - ex.printStackTrace(); } - } - try { + notification = MusicControlModule.INSTANCE.notification .prepareNotification(MusicControlModule.INSTANCE.nb, false); // call startForeground just after startForegroundService.