Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Commit 73dff60

Browse files
authored
exception handling added for the regular fixes on these lines
1 parent f925c42 commit 73dff60

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

android/src/main/java/com/tanguyantoine/react/MusicControlNotification.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,19 @@ public void forceForeground() {
215215
ContextCompat.startForegroundService(MusicControlNotification.NotificationService.this, intent);
216216

217217
if(MusicControlModule.INSTANCE == null){
218-
MusicControlModule.INSTANCE.init();
218+
try {
219+
MusicControlModule.INSTANCE.init();
220+
}catch (Exception ex){
221+
ex.printStackTrace();
222+
}
219223
}
220-
notification = MusicControlModule.INSTANCE.notification.prepareNotification(MusicControlModule.INSTANCE.nb, false);
221-
// call startForeground just after startForegroundService.
222-
startForeground(MusicControlModule.INSTANCE.getNotificationId(), notification);
224+
try {
225+
notification = MusicControlModule.INSTANCE.notification.prepareNotification(MusicControlModule.INSTANCE.nb, false);
226+
// call startForeground just after startForegroundService.
227+
startForeground(MusicControlModule.INSTANCE.getNotificationId(), notification);
228+
}catch (Exception ex){
229+
ex.printStackTrace();
230+
}
223231
}
224232
}
225233

@@ -243,10 +251,18 @@ public void onCreate() {
243251
public int onStartCommand(Intent intent, int flags, int startId) {
244252
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
245253
if (MusicControlModule.INSTANCE == null) {
246-
MusicControlModule.INSTANCE.init();
254+
try {
255+
MusicControlModule.INSTANCE.init();
256+
}catch (Exception ex){
257+
ex.printStackTrace();
258+
}
259+
}
260+
try {
261+
notification = MusicControlModule.INSTANCE.notification.prepareNotification(MusicControlModule.INSTANCE.nb, false);
262+
startForeground(MusicControlModule.INSTANCE.getNotificationId(), notification);
263+
}catch (Exception ex){
264+
ex.printStackTrace();
247265
}
248-
notification = MusicControlModule.INSTANCE.notification.prepareNotification(MusicControlModule.INSTANCE.nb, false);
249-
startForeground(MusicControlModule.INSTANCE.getNotificationId(), notification);
250266
}
251267
return START_NOT_STICKY;
252268
}

0 commit comments

Comments
 (0)