-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(android): prevent RemoteServiceException in foreground service
handled the following raise condition: when stopSelf() is called before startForeground then it will lead to a crash -> `Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{ab29442 u0 live.friend.dostt/app.notifee.core.ForegroundService c:live.friend.dostt}` To easily reproduce this crash just call the `stopSelf()` method before calling `startForeground()` method solution: we have to make sure to call `startForeground` before calling `stopSelf()`, for this, i've added a dummy notification to ensure `startForeground` is always called before calling `stopSelf()`, with `notification id 1`. This will prevent the crash `ForegroundServiceDidNotStartInTimeException`
- Loading branch information
1 parent
b73c76d
commit f5c0a25
Showing
1 changed file
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters