Skip to content

[Android] VideoPlaybackService crashes on Android 8+ (O) — missing NotificationChannel before startForeground() #4892

@naveenkumar-kv

Description

@naveenkumar-kv

Bug description

When showNotificationControls is enabled, VideoPlaybackService.onUpdateNotification() calls startForeground() with a notification but never creates a NotificationChannel. On Android 8.0+ (API 26+), this throws:

android.app.RemoteServiceException: Bad notification for startForeground

Steps to reproduce

Set showNotificationControls={true} on

A NotificationChannel should be created before startForeground() is called:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
    notificationManager.createNotificationChannel(
        NotificationChannel(
            NOTIFICATION_CHANEL_ID,
            NOTIFICATION_CHANEL_ID,
            NotificationManager.IMPORTANCE_LOW
        )
    )
}
startForeground(mediaSession.player.hashCode(), buildNotification(mediaSession))

Platform: Android 8.0+ (API 26+)
Version: 6.10.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions