Skip to content

setForegroundServiceTimeoutMs called before setMediaNotificationProvider will silently break setMediaNotificationProvider #2305

@nift4

Description

@nift4

Version

Media3 1.6.0

More version details

No response

Devices that reproduce the issue

any

Devices that do not reproduce the issue

N/A

Reproducible in the demo app?

Yes

Reproduction steps

        setForegroundServiceTimeoutMs(120000)
        setMediaNotificationProvider(
            DefaultMediaNotificationProvider.Builder(this)
                .build()
                .also { it.setSmallIcon(androidx.media3.session.R.drawable.media3_icon_heart_filled) }
        )

in onCreate

Expected result

Heart icon in notification

Actual result

Custom media notification provider is not applied, default provider (-> default icon) is used.

setForegroundServiceTimeoutMs instantiates the MediaNotificationManager, which reads from this.mediaNotificationProvider field, but if we set the field after manager is already created, nothing will happen.

I believe this should be documented, and setMediaNotificationProvider() should just throw IllegalStateException if MediaNotificationManager already created.

Media

Not applicable

Bug Report

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions