Closed johngray1965 closed 3 days ago
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
toshouldStartForegroundService
. We will update this issue when this lands in the main branch.
Thank you. That'll be very helpful.
The change is available in main
and will be included in the next release. Thanks for the suggestion!
[REQUIRED] Use case description
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).
Note, this is with 1.5.0-rc01