@@ -215,11 +215,19 @@ public void forceForeground() {
215
215
ContextCompat .startForegroundService (MusicControlNotification .NotificationService .this , intent );
216
216
217
217
if (MusicControlModule .INSTANCE == null ){
218
- MusicControlModule .INSTANCE .init ();
218
+ try {
219
+ MusicControlModule .INSTANCE .init ();
220
+ }catch (Exception ex ){
221
+ ex .printStackTrace ();
222
+ }
219
223
}
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
+ }
223
231
}
224
232
}
225
233
@@ -243,10 +251,18 @@ public void onCreate() {
243
251
public int onStartCommand (Intent intent , int flags , int startId ) {
244
252
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
245
253
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 ();
247
265
}
248
- notification = MusicControlModule .INSTANCE .notification .prepareNotification (MusicControlModule .INSTANCE .nb , false );
249
- startForeground (MusicControlModule .INSTANCE .getNotificationId (), notification );
250
266
}
251
267
return START_NOT_STICKY ;
252
268
}
0 commit comments