mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add context as a parameter to shouldStartForegroundService
Issue: androidx/media#1887 PiperOrigin-RevId: 697650546
This commit is contained in:
parent
fff6e2e169
commit
9ae136becb
@ -335,6 +335,9 @@ This release includes the following changes since the
|
|||||||
* Improve interoperability behavior, so that a Media3 browser that is
|
* Improve interoperability behavior, so that a Media3 browser that is
|
||||||
connected to a legacy `MediaBrowserService` doesn't request the children
|
connected to a legacy `MediaBrowserService` doesn't request the children
|
||||||
of a `parentId` twice when subscribing to a parent.
|
of a `parentId` twice when subscribing to a parent.
|
||||||
|
* Add 'Context' as a parameter to
|
||||||
|
'MediaButtonReceiver.shouldStartForegroundService`
|
||||||
|
([#1887](https://github.com/androidx/media/issues/1887)).
|
||||||
* UI:
|
* UI:
|
||||||
* Make the stretched/cropped video in
|
* Make the stretched/cropped video in
|
||||||
`PlayerView`-in-Compose-`AndroidView` workaround opt-in, due to issues
|
`PlayerView`-in-Compose-`AndroidView` workaround opt-in, due to issues
|
||||||
|
@ -148,7 +148,7 @@ public class MediaButtonReceiver extends BroadcastReceiver {
|
|||||||
ComponentName mediaButtonServiceComponentName = getServiceComponentByAction(context, action);
|
ComponentName mediaButtonServiceComponentName = getServiceComponentByAction(context, action);
|
||||||
if (mediaButtonServiceComponentName != null) {
|
if (mediaButtonServiceComponentName != null) {
|
||||||
intent.setComponent(mediaButtonServiceComponentName);
|
intent.setComponent(mediaButtonServiceComponentName);
|
||||||
if (!shouldStartForegroundService(intent)) {
|
if (!shouldStartForegroundService(context, intent)) {
|
||||||
Log.i(
|
Log.i(
|
||||||
TAG,
|
TAG,
|
||||||
"onReceive(Intent) does not start the media button event target service into the"
|
"onReceive(Intent) does not start the media button event target service into the"
|
||||||
@ -186,13 +186,15 @@ public class MediaButtonReceiver extends BroadcastReceiver {
|
|||||||
* playback to get into the foreground or the system will crash the service with a {@code
|
* playback to get into the foreground or the system will crash the service with a {@code
|
||||||
* ForegroundServiceDidNotStartInTimeException} or an {@link IllegalStateException}.
|
* ForegroundServiceDidNotStartInTimeException} or an {@link IllegalStateException}.
|
||||||
*
|
*
|
||||||
|
* @param context The {@link Context} that {@linkplain #onReceive(Context, Intent) was received by
|
||||||
|
* the media button event receiver}.
|
||||||
* @param intent The intent that {@linkplain #onReceive(Context, Intent) was received by the media
|
* @param intent The intent that {@linkplain #onReceive(Context, Intent) was received by the media
|
||||||
* button event receiver}.
|
* button event receiver}.
|
||||||
* @return true if the service should be {@linkplain ContextCompat#startForegroundService(Context,
|
* @return true if the service should be {@linkplain ContextCompat#startForegroundService(Context,
|
||||||
* Intent) started as a foreground service}. If false is returned the service is not started
|
* Intent) started as a foreground service}. If false is returned the service is not started
|
||||||
* and the receiver call is a no-op.
|
* and the receiver call is a no-op.
|
||||||
*/
|
*/
|
||||||
protected boolean shouldStartForegroundService(Intent intent) {
|
protected boolean shouldStartForegroundService(Context context, Intent intent) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user