Skip to content

Commit

Permalink
Merge pull request #19987 from wordpress-mobile/fix/18714-prevent-bac…
Browse files Browse the repository at this point in the history
…kground-upload-crash

Prevents the app from crashing when the foreground service fails to start
  • Loading branch information
Antonis Lilis authored Jan 22, 2024
2 parents 0a46d08 + 861cdb4 commit 585f83e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ private synchronized void startOrUpdateForegroundNotification(@Nullable PostImmu
updateNotificationBuilder(post);
if (sNotificationData.mNotificationId == 0) {
sNotificationData.mNotificationId = (new Random()).nextInt();
mService.startForeground(sNotificationData.mNotificationId, mNotificationBuilder.build());
try {
mService.startForeground(sNotificationData.mNotificationId, mNotificationBuilder.build());
} catch (RuntimeException exception) {
AppLog.e(T.POSTS, "startOrUpdateForegroundNotification failed; See issue #18714", exception);
}
} else {
// service was already started, let's just modify the notification
doNotify(sNotificationData.mNotificationId, mNotificationBuilder.build(), null);
Expand Down

0 comments on commit 585f83e

Please sign in to comment.