Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted to start a foreground service with a broken notification. #2049

Closed
puckey opened this issue Jun 29, 2023 · 1 comment · Fixed by #2048
Closed

Attempted to start a foreground service with a broken notification. #2049

puckey opened this issue Jun 29, 2023 · 1 comment · Fixed by #2048

Comments

@puckey
Copy link
Collaborator

puckey commented Jun 29, 2023

Describe the Bug
I am seeing the following error in adb output on android: "ActivityManager: Attempted to start a foreground service (com.example/com.doublesymmetry.trackplayer.service.MusicService) with a broken notification (no icon: Notification(channel=temporary_channel shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 category=service vis=PRIVATE))"

Steps To Reproduce
Start the example on an android device and look at the adb output

Environment Info:
main branch
testing on a Pixel 3a

How I can Help
Looking at the message it seems to be because no icon is provided in the following notification: https://github.com/doublesymmetry/react-native-track-player/blob/main/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt#L114

I will look into fixing this – not sure what to use for an icon though.

puckey added a commit to puckey/react-native-track-player that referenced this issue Jun 29, 2023
Using `ExoPlayerR.drawable.exo_notification_small_icon` which is exoplayer’s default notification icon.
@puckey
Copy link
Collaborator Author

puckey commented Jun 29, 2023

This pr includes a fix: #2048

@dcvz dcvz closed this as completed in #2048 Jul 4, 2023
dcvz pushed a commit that referenced this issue Jul 4, 2023
* fix(android): foreground issues (close #2045)

- move execution of foregrounding and backgrounding to NotificationState.POSTED in order to avoid race condition where notificationId has not been set yet
- avoid comparing to player states that don’t affect foregrounding, by ignoring LOADING, BUFFERING and READY states – all of which can occur both when playing or while paused
- also avoid the initial IDLE state, since we are only interested when the player would become idle (i.e. all tracks were removed)
- ENDED state should also cause foregrounding to stop (without removing notification)

* Fix: Add missing icon to notification (close #2049)

Using `ExoPlayerR.drawable.exo_notification_small_icon` which is exoplayer’s default notification icon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant