-
Notifications
You must be signed in to change notification settings - Fork 390
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
App crashes if skip notification action is used while paused #20
Comments
I think the behavior of the service looks correct and sensible to me, except that when paused, the The general approach is to remove the service from the foreground when That's what happens when the skip buttons are pressed in that state. A notification action results in media button action ( With the current implementation and design, the missing piece when in the described state, is hiding all actions except such actions that put the service into the foreground after begin executed. I look into doing this. |
I agree, the service foreground/background behavior with My issue is with the actions you can do when the app is in that period where the service is in the background and the OS hasn't removed it yet. One fix is, like you said, hiding those actions but, wouldn't it be easier if the actions know what is expected from them and do the right call? I mean, right now the |
@spun, thanks for your feedback. We submitted a fix as per your recommendation . I will close this issue once the commit is included in an upcoming release. |
This change makes all notification actions start MediaSessionService in the background except COMMAND_PLAY which starts the service in the foreground. This is to avoid ANRs that are raised if we don't call MediaSessionService.startForeground() within 5 seconds since the service was started in the foreground. We only call MediaSessionService.startForeground() when Player.getPlayWhenReady() returns true, and only COMMAND_PLAY sets playWhenReady to true. Issue: #20 #minor-release PiperOrigin-RevId: 433229604
Closing as this is fixed and will land in the next release. |
Steps to reproduce
MediaLibraryService
/MediaSessionService
The app will crash with:
Cause
MediaNotificationHandler method createPendingIntent() is used for the creation of its
NotificationCompat.Action
s. This method decides to callgetService
orgetForegroundService
and it correctly checks forPAUSE
andSTOP
actions that won't put the service in the foreground, but there are more actions that should be considered.ACTION_SKIP_TO_PREVIOUS
,ACTION_SKIP_TO_NEXT
and many more actions won't put the service in the foreground and all of them will crash the app ifgetForegroundService
is used.Also, I think that
media2
has the same createPendingIntent and probably has the same problem.The text was updated successfully, but these errors were encountered: