Skip to content

Commit a17d794

Browse files
committed
Ignoring security exception when service cannot be started in fg
1 parent be49535 commit a17d794

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,12 @@ private void startForeground() {
19221922
// Any additional configuration?
19231923
updateForegroundNotification(builder);
19241924

1925-
startForeground(NOTIFICATION_ID, builder.build());
1925+
try {
1926+
startForeground(NOTIFICATION_ID, builder.build());
1927+
} catch (final SecurityException e) {
1928+
loge("Service cannot be started in foreground", e);
1929+
logi("Starting DFU service in background instead");
1930+
}
19261931
}
19271932

19281933
/**

0 commit comments

Comments
 (0)