Skip to content

Commit 0ca9661

Browse files
committed
Catch (Foreground|Background)ServiceStartNotAllowedException
1 parent cd21ed0 commit 0ca9661

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

android/src/main/java/io/wazo/callkeep/VoiceConnectionService.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,12 @@ private void startForegroundService() {
335335
Log.d(TAG, "[VoiceConnectionService] Starting foreground service");
336336

337337
Notification notification = notificationBuilder.build();
338-
startForeground(FOREGROUND_SERVICE_TYPE_MICROPHONE, notification);
338+
339+
try {
340+
startForeground(FOREGROUND_SERVICE_TYPE_MICROPHONE, notification);
341+
} catch (Exception e) {
342+
Log.w(TAG, "[VoiceConnectionService] Can't start foreground service : " + e.toString());
343+
}
339344
}
340345

341346
private void stopForegroundService() {
@@ -347,7 +352,11 @@ private void stopForegroundService() {
347352
return;
348353
}
349354

350-
stopForeground(FOREGROUND_SERVICE_TYPE_MICROPHONE);
355+
try {
356+
stopForeground(FOREGROUND_SERVICE_TYPE_MICROPHONE);
357+
} catch (Exception e) {
358+
Log.w(TAG, "[VoiceConnectionService] can't stop foreground service :" + e.toString());
359+
}
351360
}
352361

353362
private boolean isForegroundServiceConfigured() {

0 commit comments

Comments
 (0)