You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pass the context to shouldStartForegroundService #1887
In order to implement androidx.media3.session.MediaButtonReceiver.shouldStartForegroundService, I need to inject something. I can either use @androidentrypoint or use @entrypoint. The former doesn't work because the dagger generated code overrides onReceive and androidx.media3.session.MediaButtonReceiver implementation of onReceive is final. The latter doesn't because I don't have context needed to use the @entrypoint.
Proposed solution
Where the androidx.media3.session.MediaButtonReceiver calls shouldStartForegroundService, it has a context. In fact it uses when it calls ContextCompat.startForegroundService, in order to correctly implement shouldStartForegroundService I need same information.
Alternatives considered
Copying the code from androidx.media3.session.MediaButtonReceiver to implement my own (not a great option).
Yup, that is a valid request. Thanks for the suggestion. We will pass the context, we get in onReceive to shouldStartForegroundService. We will update this issue when this lands in the main branch.
Yup, that is a valid request. Thanks for the suggestion. We will pass the context, we get in onReceive to shouldStartForegroundService. We will update this issue when this lands in the main branch.
Activity
marcbaechinger commentedon Nov 14, 2024
Yup, that is a valid request. Thanks for the suggestion. We will pass the context, we get in
onReceivetoshouldStartForegroundService. We will update this issue when this lands in the main branch.johngray1965 commentedon Nov 14, 2024
Thank you. That'll be very helpful.
Add context as a parameter to shouldStartForegroundService
marcbaechinger commentedon Nov 18, 2024
The change is available in
mainand will be included in the next release. Thanks for the suggestion!